-
Notifications
You must be signed in to change notification settings - Fork 1
/
youtube-playlist-loadall.js
40 lines (32 loc) · 1.21 KB
/
youtube-playlist-loadall.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
37
38
39
40
function clickLoadMoreUntilItDoesntExist() {
chrome.runtime.sendMessage({action: "hideIcon"}, function(response) {});
if ($(".load-more-button").length == 0) {
return;
}
$(".load-more-button").first().click();
window.setTimeout(function () {
clickLoadMoreUntilItDoesntExist();
window.scrollTo(0,document.body.scrollHeight);
}, 500);
}
function watchButton() {
window.setTimeout(watchButton, 700);
if (location.pathname != '/playlist' || $(".load-more-button").length == 0 || $(".load-more-button").first().is(":disabled")) {
chrome.runtime.sendMessage({action: "hideIcon"}, function(response) {});
return;
}
chrome.runtime.sendMessage({action: "showIcon"}, function(response) {});
}
/*
(document.body || document.documentElement).addEventListener('transitionend', function(event) {
if (event.propertyName === 'width' && event.target.id === 'progress') {
watchButton();
}
}, true);*/
watchButton();
// Listen for background messages
chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) {
if (request.action == 'clickLoadMoreUntilItDoesntExist') {
clickLoadMoreUntilItDoesntExist();
}
});