-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathContentScript.js
More file actions
29 lines (27 loc) · 870 Bytes
/
ContentScript.js
File metadata and controls
29 lines (27 loc) · 870 Bytes
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
chrome.runtime.onMessage.addListener(
function(request, sender, sendResponse) {
if (request.message === 'ytvideoid') {
SponsorsLookup(request.id);
}
});
function SponsorsLookup(id) {
v = document.querySelector('video')
var xmlhttp = new XMLHttpRequest();
xmlhttp.open('GET', 'https://officialnoob.github.io/YTSponsorSkip-Dataset/' + id, true);
xmlhttp.onreadystatechange = function () {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
Sponsors = JSON.parse(xmlhttp.responseText);
v.ontimeupdate = function () {
SponsorCheck(Sponsors);
};
}
};
xmlhttp.send(null);
}
function SponsorCheck(Sponsors) {
Sponsors.forEach(function (el, index) {
if ((Math.floor(v.currentTime)) == el[0]) {
v.currentTime = el[1];
}
});
}