Skip to content

Instantly share code, notes, and snippets.

@thesephist
Created December 24, 2016 05:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thesephist/30004dd450d000126d54b3303f0056ed to your computer and use it in GitHub Desktop.
Save thesephist/30004dd450d000126d54b3303f0056ed to your computer and use it in GitHub Desktop.
Youtube Bookmarklets
console.log("YTFixer Enabled");var xsp=document.getElementById("player"),xsh=document.getElementById("placeholder-player"),xsw=document.getElementById("watch7-content"),xst,xso,xsn=document.getElementById("watch7-sidebar-contents");function YTFix(){xst=document.getElementById("theater-background").clientHeight;xtn=(xst+10).toString()+"px";xsp.style.position="fixed";xsh.style.display="none";xsp.style.top="62px";xsp.style.zIndex="10";xsw.style.position="relative";xsw.style.top=xtn;if(xst==720){xsp.style.marginLeft="calc(50% - 853px)"}else if(xst==480){xsp.style.marginLeft="calc(50% - 640px)"}else if(xst==360){xsp.style.marginLeft="calc(50% - 533px)"}else if(xst==240){xsp.style.marginLeft="calc(50% - 213px)"}else{xsp.style.marginLeft="100px"}if(window.innerWidth<=1084 && window.innerWidth>640){xsp.style.marginLeft="0"};if(window.innerWidth>640){xsn.style.position="relative";xsn.style.top=xtn}console.log("YT Video Fixed by YTFixer")};function hashX(){if(window.location.href.indexOf("://www.youtube.com/watch")>-1){YTFix();window.addEventListener("resize",function(){clearTimeout(xso);xso=setTimeout(YTFix,150)})}}hashX();window.addEventListener("hashchange",hashX);if(true){if(document.getElementsByClassName("ytp-size-button")[0]!=null){if(document.getElementsByClassName("ytp-size-button")[0].getAttribute("title")=="Default view"){alert("It looks like you have Theater Mode enabled. YTFixer does not work as well in Theater Mode, but you can still use it.")}}}
if(document.getElementsByClassName("ytp-play-button").length<1){alert("Oops! Something went wrong. Are you sure you are watching a YouTube video on its own page?")}else{console.log("YTReplay clicked");function xqc(el,etype){if(el.fireEvent){el.fireEvent("on"+etype)}else{var evObj=document.createEvent("Events");evObj.initEvent(etype,true,false);el.dispatchEvent(evObj)}}var wca=document.getElementsByClassName("ytp-play-button")[0],apx,xkq;function syt(){apx=setInterval(function(){if(wca.getAttribute("title")=="Replay" || wca.getAttribute("title")=="Replay"){xqc(wca,"click")}else if(window.location.href.indexOf("//www.youtube.com/watch")==-1){uyt()}},1500);alert("YTReplay auto-repeat enabled");xkq=true}function uyt(){clearInterval(apx);alert("YTReplay auto-repeat disabled");xkq=false}if(xkq==true){uyt()}else{syt()}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment