forked from Deskbot/No-Playlist-Autoplay-For-YouTube
-
Notifications
You must be signed in to change notification settings - Fork 0
/
content.js
28 lines (25 loc) · 987 Bytes
/
content.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
chrome.storage.local.get(['autoplay', 'frequency'], function(result) {
if (!result.autoplay) { //do not allow autoplay
if (result.frequency) {
result.frequency = result.frequency < 1000 ? 1000 : result.frequency;
} else {
result.frequency = 5000; //sometimes the data is lost by chrome
}
var script = document.createElement("script");
script.id = "npafy-script";
script.type = "text/javascript";
script.innerText += "(function() {";
script.innerText += " var ypm;";
script.innerText += " function f() {";
script.innerText += " if (ypm) {";
script.innerText += " ypm.canAutoAdvance_ = false;";
script.innerText += " } else {";
script.innerText += " ypm = document.getElementsByTagName('yt-playlist-manager')[0];";
script.innerText += " }";
script.innerText += " }";
script.innerText += " f();";
script.innerText += " setInterval(f, " + result.frequency + ");";
script.innerText += "})();";
document.body.appendChild(script);
}
});