Last active
March 1, 2016 20:39
-
-
Save gabrielkw/ca5a451e3c7704282adc to your computer and use it in GitHub Desktop.
Save the verical scrolling status of your navigation for later restoring
This file contains 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
// ==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"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.