-
Notifications
You must be signed in to change notification settings - Fork 1
/
CrunchyRoll.Skips.user.js
62 lines (62 loc) · 2.22 KB
/
CrunchyRoll.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
// ==UserScript==
// @name Crunchy Roll Skips
// @namespace https://github.com/N3Cr0Cr0W/userscripts
// @version 0.5
// @description Plays next episode, Skips Intro, Preview and Recap
// @author N3Cr0Cr0W
// @downloadURL https://raw.githubusercontent.com/N3Cr0Cr0W/userscripts/master/CrunchyRoll.Skips.user.js
// @updateURL https://raw.githubusercontent.com/N3Cr0Cr0W/userscripts/master/CrunchyRoll.Skips.user.js
// @match https://static.crunchyroll.com/vilos-v2/*
// @grant GM_log
// ==/UserScript==
(function(){
'use strict';
let urlPathName="";
let videoPlayer="";
function tEvent(){
const newVideoPlayer=document.querySelector('video');
const newUrlPathName=window.location.pathname;
if(newUrlPathName!==urlPathName||videoPlayer!=newVideoPlayer){
mutObserver.disconnect();
mutObserver.observe(appMountPoint,{childList:true,subtree:true});
var checkExist = setInterval(function(){
const newVideoPlayer=document.querySelector('video');
videoPlayer=newVideoPlayer;
if (videoPlayer){
clearInterval(checkExist);
}
}, 100);
urlPathName=newUrlPathName;
}
}
const appMountPoint=document.getElementById("vilos");
const mutObserver=new MutationObserver(mutations=>{
mutations.forEach(mutation=>{
if(mutation.nextSibling&&mutation.addedNodes.length){
Array.from(mutation.addedNodes).filter(node=>{
if(node.className==="end-card-container"){
setTimeout(()=>{document.querySelector(".end-card__metadata-area-play-button").click();},200);
GM_log('Next Ep');
}
});
}else if(!mutation.nextSibling&&mutation.addedNodes.length==1){
Array.from(mutation.addedNodes).filter(node=>{
if(node.innerText==="SKIP INTRO"){
setTimeout(()=>{node.children[0].click();},200);
GM_log('Skip Intro');
}else if(node.innerText==="SKIP CREDITS"){
setTimeout(()=>{node.children[0].click();},200);
GM_log('Skip Credits');
}else if(node.innerText==="SKIP RECAP"){
setTimeout(()=>{node.children[0].click();},200);
GM_log('Skip Recap');
}else if(node.innerText==="SKIP PREVIEW"){
setTimeout(()=>{node.children[0].click();},200);
GM_log('Skip Preview');
}
});
}
});
});
const inteWatch=setInterval(tEvent,3000);
})();