Skip to content

Instantly share code, notes, and snippets.

@shuding
Created October 31, 2014 14:45
Show Gist options
  • Save shuding/3c62955dfb7c0335f37f to your computer and use it in GitHub Desktop.
Save shuding/3c62955dfb7c0335f37f to your computer and use it in GitHub Desktop.
V2EX (background) reader
// ==UserScript==
// @name V2EX reader
// @namespace http://github.com/quietshu
// @version 0.1
// @description enter something useful
// @match http://www.v2ex.com/
// @copyright 2012+, You
// ==/UserScript==
;(function() {
var hidden = "webkitHidden",
visibilityChange = "webkitvisibilitychange";
var state = document[hidden];
var title = "V2EX";
if (state) {
title = document.getElementsByClassName("item_title")[0].innerText;
document.title = title;
}
function handleVisibilityChange() {
if (document[hidden]) {
title = document.getElementsByClassName("item_title")[0].innerText;
document.title = title;
} else {
document.title = "V2EX";
}
state = document[hidden];
}
document.addEventListener(visibilityChange, handleVisibilityChange, false);
setTimeout(function() {
if (state)
window.location.reload();
}, 10000);
})();
@shuding
Copy link
Author

shuding commented Oct 31, 2014

Just for my Chrome (webkit).

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