Created
October 31, 2014 14:45
-
-
Save shuding/3c62955dfb7c0335f37f to your computer and use it in GitHub Desktop.
V2EX (background) reader
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 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); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Just for my Chrome (webkit).