-
Notifications
You must be signed in to change notification settings - Fork 0
/
likes.js
36 lines (36 loc) · 1.17 KB
/
likes.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
$('button#startcrawl').click(function() {
chrome.runtime.sendMessage({type: "getLikes"}, function(response) {
console.log(response);
});
$(this).html('Crawling...');
$(this).attr("disabled", true);
});
chrome.runtime.onMessage.addListener(
function(request, sender, sendResponse) {
console.log(sender.tab ?
"from a content script:" + sender.tab.url :
"from the extension");
if (request.type == "appendLikesList") {
if ( !request.payload ) {
// Done
$('button#startcrawl').html('Done crawl');
$('h1').text('Likes ('+$('li').length+')');
console.log("Crawling likes done");
sendResponse({ 'stop': true });
} else {
adding = $(request.payload);
console.log(adding);
new_cursor = adding.find('li:last-child button.PageLikedButton').attr('data-profileid');
console.log(new_cursor);
if ( $('ul.uiList').length ) {
$('ul.uiList:first').append(adding[0].children);
} else {
$('ul#likes').after(adding);
}
sendResponse({ 'cursor': new_cursor });
}
} else if ( request.type == "saveFriendListDone" ) {
$('button#startcrawl').html('Done crawl, saving done');
}
return true;
});