aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorOfficial Noob <[email protected]>2018-06-23 16:09:05 +0100
committerGitHub <[email protected]>2018-06-23 16:09:05 +0100
commitdb9ebe4b3f30bb8bc60eab9e1d10b87ee3f8be2a (patch)
treeb35458cefc446666c5f606412a5b556b45c2fcd8
parent4c84e38490fc0ad598d9b4f58f42772bf64a5905 (diff)
downloadSponsorBlock-db9ebe4b3f30bb8bc60eab9e1d10b87ee3f8be2a.tar.gz
SponsorBlock-db9ebe4b3f30bb8bc60eab9e1d10b87ee3f8be2a.zip
Run with jsbeautifier
http://jsbeautifier.org/
-rw-r--r--ContentScript.js45
1 files changed, 24 insertions, 21 deletions
diff --git a/ContentScript.js b/ContentScript.js
index 44f6aa29..571eb9fb 100644
--- a/ContentScript.js
+++ b/ContentScript.js
@@ -1,31 +1,34 @@
var v = document.querySelector('video')
video_id = youtube_parser(document.URL);
-if(video_id){
-SponsorsLookup(video_id);
+if (video_id) {
+ SponsorsLookup(video_id);
}
-
-function SponsorsLookup(id){
-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()};
- }
-};
-xmlhttp.send(null);
+
+function SponsorsLookup(id) {
+ 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()
+ };
+ }
+ };
+ xmlhttp.send(null);
}
-
+
function SponsorCheck() {
- Sponsors.forEach(function(el, index) {
- if((Math.floor(v.currentTime)) == el[0]){
- v.currentTime = el[1];
- }
-});}
+ Sponsors.forEach(function (el, index) {
+ if ((Math.floor(v.currentTime)) == el[0]) {
+ v.currentTime = el[1];
+ }
+ });
+}
-function youtube_parser(url){
+function youtube_parser(url) {
var regExp = /^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#\&\?]*).*/;
var match = url.match(regExp);
- return (match&&match[7].length==11)? match[7] : false;
+ return (match && match[7].length == 11) ? match[7] : false;
}