-
Notifications
You must be signed in to change notification settings - Fork 1
/
Hulu.Skips.user.js
73 lines (72 loc) · 2.62 KB
/
Hulu.Skips.user.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
// ==UserScript==
// @name Hulu Skips
// @namespace https://github.com/N3Cr0Cr0W/userscripts
// @version 0.3
// @description Plays next episode, exits if random show.
// @author N3Cr0Cr0W
// @downloadURL https://raw.githubusercontent.com/N3Cr0Cr0W/userscripts/master/Hulu.Skips.user.js
// @updateURL https://raw.githubusercontent.com/N3Cr0Cr0W/userscripts/master/Hulu.Skips.user.js
// @match https://www.hulu.com/*
// @grant GM_log
// @grant GM_setValue
// @grant GM_getValue
// @grant GM_registerMenuCommand
// ==/UserScript==
(function(){
'use strict';
let playback="";
let urlPathName="";
let videoPlayer="";
let appMountPoint="";
let controlsMountPoint="";
function tEvent(){
const newVideoPlayer=document.querySelector('video');
const newUrlPathName=window.location.pathname;
if(newUrlPathName!==urlPathName||videoPlayer!=newVideoPlayer){
var checkExistEndCard = setInterval(function(){
const newAppMountPoint=document.querySelector('div#web-player-app');
appMountPoint=newAppMountPoint;
if(appMountPoint){
GM_log(appMountPoint);
mutObserver.disconnect();
mutObserver.observe(appMountPoint,{childList:true,subtree:true,attributes:true});
var checkForControls = setInterval(function(){
const newControlsMountPoint=document.querySelector('div#ControlsContainer');
controlsMountPoint=newControlsMountPoint;
if(controlsMountPoint){
mutObserver.observe(controlsMountPoint,{childList:true,subtree:true,attributes:true});
clearInterval(checkForControls);
}
}, 100);
clearInterval(checkExistEndCard);
}
}, 100);
urlPathName=newUrlPathName;
}
}
const mutObserver=new MutationObserver(mutations=>{
mutations.forEach(mutation=>{
if(
mutation.type==='attributes'&&
mutation.target.className==='ControlsContainer__transition'&&
mutation.attributeName==='style'&&
mutation.target.children.length===1&&
mutation.target.children[0].className==='SkipButton'&&
mutation.target.style.opacity==="1"
){
GM_log('Skip Intro');
mutation.target.children[0].children[0].click();
}
if(mutation.attributeName=="class"&&mutation.target.classList[1]=="end-card-container--show"){
setTimeout(()=>{document.querySelector(".end-card__metadata-area-play-button").click();},200);
GM_log('Next Ep');
}
if(mutation.attributeName=="class"&&mutation.target.classList[1]=="NetworkBug"){
document.querySelector('img.NetworkBug').removeAttribute('src');
document.querySelector('img.NetworkBug').style.display='hidden';
GM_log('Remove Network Logo');
}
});
});
const inteWatch=setInterval(tEvent,3000);
})();