Skip to content

Instantly share code, notes, and snippets.

@gabrielkw
Last active March 1, 2016 20:39
Show Gist options
  • Save gabrielkw/ca5a451e3c7704282adc to your computer and use it in GitHub Desktop.
Save gabrielkw/ca5a451e3c7704282adc to your computer and use it in GitHub Desktop.
Save the verical scrolling status of your navigation for later restoring
// ==UserScript==
// @name Save Scrolling by Gabriel Antunes
// @namespace saveScrolling
// @include *
// @version 1
// @grant GM_registerMenuCommand
// ==/UserScript==
function saveScrolling(){
localStorage.setItem(window.location.pathname,window.pageYOffset);
}
function restoreScrolling(){
window.scrollTo(0,localStorage.getItem(window.location.pathname));
}
GM_registerMenuCommand("Save Scrolling", saveScrolling, "s");
GM_registerMenuCommand("Restore Scrolling", restoreScrolling, "r");
@gabrielkw
Copy link
Author

To use this script, install Greasemonkey for Firefox or Tampermonkey for Google Chrome.
With Greasemonkey or Tampermonkey installed, you can click here to install this script.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment