-
Notifications
You must be signed in to change notification settings - Fork 56
/
Copy pathytscroller.min.js
1 lines (1 loc) · 1.92 KB
/
ytscroller.min.js
1
javascript:krazete:function videoAnchor(){var e,t,n,i,o,l,d,s,r;document.getElementsByClassName("miniplayer")[0].parentElement.active||(e=document.getElementById("movie_player"),t=document.getElementsByTagName("video")[0],n=document.getElementsByClassName("ytp-chrome-bottom")[0],i=document.getElementById("masthead-container").getBoundingClientRect(),s=document.querySelector("#player-container.ytd-watch-flexy").getBoundingClientRect(),e.removeAttribute("style"),o=e.getBoundingClientRect(),l=t.getBoundingClientRect(),s.bottom<i.height?(s=(document.getElementById("primary-inner")||document.getElementById("primary")).getBoundingClientRect(),d=320/l.width,s=(window.innerWidth-s.right)/l.width,r=(window.innerHeight-i.height)/l.height,e.style.position="fixed",e.style.right="0",e.style.top=i.height+"px",e.style.width=l.width+"px",e.style.height=l.height+"px",e.style.transformOrigin="right top",e.style.transform="scale("+Math.max(d,Math.min(s,r))+")",e.style.zIndex="1500",n.style.left="12px",n.style.width=l.width-24+"px",t.style.left=0):(n.style.left="12px",n.style.width=o.width-24+"px",t.style.left=(o.width-l.width)/2+"px"))}window.addEventListener("scroll",videoAnchor),window.addEventListener("resize",videoAnchor),(()=>{var i,o,t=document.createElement("div");t.textContent="▼",t.style.background="red",t.style.color="white",t.style.fontSize="24px",t.style.position="absolute",t.style.left="50%25",t.style.top="0",t.style.transform="translateX(-50%25)",t.style.display="none",t.style.borderRadius="0 0 8px 8px",t.style.zIndex="8000",t.style.cursor="pointer",document.body.appendChild(t),window.addEventListener("mouseup",function(e){var n;(e=e.target.closest("a"))&&/[?&]t=\d+s/.test(e.href)&&(i=window.scrollX,o=window.scrollY,t.style.display="block",requestAnimationFrame(function e(t){window.scrollTo(i,o),t-(n=void 0===n?t:n)<1&&requestAnimationFrame(e)}))}),t.addEventListener("click",function(){t.style.display="none",window.scrollTo(i,o)})})();