Last active
June 11, 2021 03:47
-
-
Save naturallucky/b7e64160e4bd8eccbd462e7cbe8c33a6 to your computer and use it in GitHub Desktop.
bookmarklet for youtube (Enhance for youtube)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript:(function (){ var v = document.querySelector('video');v.playbackRate = 1.0;})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//switching version | |
(function (){ | |
var v = document.querySelector('video'); | |
if (v.playbackRate == 1.0){ | |
v.playbackRate = 0.7; | |
}else if (v.playbackRate == 0.7){ | |
v.playbackRate = 1.4; | |
}else{ | |
v.playbackRate = 1.0; | |
} | |
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//unser construction | |
var launchTimeXXX = launchTimeXXX | 0; | |
function ytc (){ | |
var v = document.querySelector('video'); | |
if (launchTimeXXX){ | |
//console.log("change:"+launchTimeXXX +" " + v.playbackRate); | |
//speed changer | |
if (v.playbackRate == 1.0){ | |
v.playbackRate = 0.7; | |
}else if (v.playbackRate == 0.7){ | |
v.playbackRate = 1.4; | |
}else{ | |
v.playbackRate = 1.0; | |
} | |
}else{ | |
//console.log("first check:"+launchTimeXXX +" " + v.playbackRate); | |
//first launching : check keyword to play normal speed | |
launchTimeXXX++; | |
let m = new RegExp("曲|song|ソング|カバー|ミュージック|cover|MV|MV|作詞|作曲|唄|歌|サッカー|天皇杯|ルヴァンカップ|AFC|UEFA"); | |
let t = document.getElementsByClassName("title");//document.getElementById("container");// | |
let ts,tag; | |
if(t){ | |
//console.log("t len:"+ t.length); | |
for (let i =0 ; i < t.length;i++){ | |
ts= t[i].innerText; | |
//console.log(" text:"+t[i].tagName+" :" +ts); | |
if (ts.match(m)){ | |
v.playbackRate = 1.0; | |
v.loop = true; | |
return; | |
} | |
tag = t[i].previousElementSibling; | |
if (t[i].tagName.toUpperCase() == "H1" && tag){ | |
for (let i =0 ; i < tag.children.length;i++){ | |
ts= tag.children[i].innerText; | |
//console.log("tag a text:"+tag.children[i].tagName+" :" +ts); | |
if (ts.match(m)){ | |
v.playbackRate = 1.0; | |
v.loop = true; | |
return; | |
} | |
} | |
} | |
} | |
} | |
//console.log("first check2:"+launchTimeXXX +" " + v.playbackRate); | |
let c = document.getElementById("description"); | |
let cs; | |
if (c){ | |
cs = c.innerText.substring(0,200); | |
//console.log(" text:"+cs); | |
if (cs.match(m)){ | |
v.playbackRate = 1.0; | |
v.loop = true; | |
return; | |
} | |
} | |
} | |
} | |
setTimeout(ytc,200); |
Also you can use this HTML5 video page.
But its code apply to only 1 of first video in page.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can change play speed at You Tube.
1.Make blank bookmark.
2.Set this script string in URL column.(and title such a "x1.0")
3.Set the bookmark on browser toolbar.
(also making many type and setting bookmarklet into folder("video" folder) is useful.
It is easily to select speed (x0.7 , x1.0 , x1.4, x2.0 , x3.0 ....)
If you use this gist at script (like Enhance for youtube browser extension), don't forget remove "javascript:" strings.
see also : https://stackoverflow.com/questions/3027707/how-to-change-the-playing-speed-of-videos-in-html5