Last active
December 31, 2017 21:02
-
-
Save DarkMatterMatt/0cda044231c3ec45fb788713e6a023cc to your computer and use it in GitHub Desktop.
AutoRefresh for Github
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
// ==UserScript== | |
// @name AutoRefresh for Github | |
// @namespace MattMoran | |
// @version 1.0 | |
// @description Automatically refreshed inactive Github tabs every 10 mins | |
// @author Matt Moran | |
// @copyright Matt Moran 2017 | |
// @match https://github.com/*/*/* | |
// @updateURL https://gist.github.com/DarkMatterMatt/0cda044231c3ec45fb788713e6a023cc/raw/ | |
// @require https://cdnjs.cloudflare.com/ajax/libs/js-cookie/2.2.0/js.cookie.min.js | |
// ==/UserScript== | |
(function() { | |
"use strict"; | |
if (Cookies.get("autoScroll")) | |
window.scrollTo(0, parseInt(Cookies.get("autoScroll"))); | |
var reload = function() { | |
Cookies.set("autoScroll", window.scrollY, {expires: 7, path: ""}); | |
window.location.reload(); | |
}; | |
setTimeout(function() { | |
if (document.hidden) reload(); | |
else { | |
document.addEventListener("visibilitychange", function() { | |
reload(); | |
}); | |
} | |
}, 10 * 60 * 1000); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment