Skip to content

Instantly share code, notes, and snippets.

@klamping
Last active October 7, 2021 21:16
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 klamping/e7564c2deb3b6d5043cf938d4d3ecf6c to your computer and use it in GitHub Desktop.
Save klamping/e7564c2deb3b6d5043cf938d4d3ecf6c to your computer and use it in GitHub Desktop.
Browser Scroll Bookmarklets
javascript:void function()%7Bconst e%3DMath.round(document.documentElement.scrollTop),o%3Ddocument.createElement("textarea")%3Bo.value%3De,document.body.appendChild(o),o.select(),document.execCommand("copy"),document.body.removeChild(o)%7D()%3B
javascript:void function()%7Bfunction n(n,t)%7Bvar i,o%3Dwindow.pageYOffset,e%3Ddocument.body.scrollHeight-n<window.innerHeight%3Fdocument.body.scrollHeight-window.innerHeight:n,r%3De-o,s%3Dfunction(n)%7Breturn.5>n%3F4*n*n*n:(n-1)*(2*n-2)*(2*n-2)%2B1%7D%3Br%26%26window.requestAnimationFrame(function c(n)%7Bi%7C%7C(i%3Dn)%3Bvar e%3Dn-i,d%3DMath.min(e/t,1)%3Bd%3Ds(d),window.scrollTo(0,o%2Br*d),t>e%26%26window.requestAnimationFrame(c)%7D)%7Dvar t%3D"Enter distance to scroll (in pixels) and the scroll duration (in seconds).%5Cn%5CnRun the script a second time with options 0 0 to reset the page.%5Cn%5CnExample:%5Cn%5Cn800 5",i%3Dprompt(t)%3Bconst o%3Di.split(" ")%3BsetTimeout(function()%7Bn(o%5B0%5D,1e3*o%5B1%5D)%7D,500)%7D()%3B
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment