Created
January 8, 2026 19:08
-
-
Save EncodeTheCode/cf7cbe45ed715b60a04d059677cc868d to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| (function addRS(){ | |
| if(document.getElementById('rs')) return; | |
| const s=document.createElement('div'), t=document.createElement('div'); | |
| s.id='rs'; Object.assign(s.style,{position:'fixed',top:0,right:0,width:'12px',height:'100%',background:'rgba(255,192,203,0.2)',zIndex:999999,cursor:'pointer'}); | |
| t.id='rst'; Object.assign(t.style,{width:'100%',height:'60px',background:'deeppink',borderRadius:'6px',position:'absolute',top:0}); | |
| s.appendChild(t); document.body.appendChild(s); | |
| let dragging=false, startY=0, startScroll=0; | |
| const update=()=>{ | |
| const sh=document.body.scrollHeight-window.innerHeight, bh=s.offsetHeight-t.offsetHeight; | |
| t.style.top = (sh && bh ? (window.scrollY/sh)*bh : 0) + 'px'; | |
| }; | |
| t.onmousedown=e=>{ dragging=true; startY=e.clientY; startScroll=window.scrollY; document.body.style.userSelect='none'; }; | |
| document.onmouseup=()=>{ dragging=false; document.body.style.userSelect=''; }; | |
| document.onmousemove=e=>{ if(!dragging) return; const sh=document.body.scrollHeight-window.innerHeight, bh=s.offsetHeight-t.offsetHeight||1, dy=e.clientY-startY; window.scrollTo(0, Math.max(0, Math.min(sh, startScroll + (dy/bh)*sh))); update(); }; | |
| window.addEventListener('scroll', update); | |
| update(); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment