Skip to content

Instantly share code, notes, and snippets.

@hitode909
Created July 30, 2010 13:20
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hitode909/500502 to your computer and use it in GitHub Desktop.
Save hitode909/500502 to your computer and use it in GitHub Desktop.
だんだんLDR読めなくする
// ==UserScript==
// @name no-more-ldr
// @namespace http://www.hatena.ne.jp/hitode909
// @include http://reader.livedoor.com/reader/
// @include http://fastladder.com/reader/
// ==/UserScript==
var index = 0;
var isFocused = true;
var cache_key;
var viewCount = 0;
function appendNoise(i) {
var source = '臨兵闘者皆陣列在前';
var noise = document.createElement('b');
noise.className = 'noise';
noise.textContent = source.charAt(index++);
if (source.length <= index) index = 0;
with(noise.style) {
zIndex = 1000000;
fontFamily = '"MS P明朝", "細明朝体", "ヒラギノ明朝 Pro W3", serif';
fontSize = (10+i) + 'px';
position = 'absolute';
left = (Math.random() * 140 - 20) + '%';
top = (Math.random() * 140 - 20) + '%';
cursor = 'pointer';
}
document.body.appendChild(noise);
}
function doing() {
return isFocused;
}
function start() {
isFocused = true;
}
function stop() {
isFocused = false;
}
function reset() {
GM_setValue('viewCount', 0);
viewCount = 0;
Array.forEach(document.querySelectorAll('.noise'), function(element) {
element.parentNode.removeChild(element);
});
}
function setup() {
GM_registerMenuCommand('no more ldr - reset', reset);
document.addEventListener('focus', function (e) {
start();
}, false);
document.addEventListener('blur', function (e) {
stop();
}, false);
document.addEventListener('click', function(e) {
var element = e.target;
if (element.className == 'noise') {
element.parentNode.removeChild(element);
}
}, false);
var d = new Date();
var period = [d.getFullYear(), d.getMonth()+1, d.getDate()].join('-');
if (GM_getValue('period') == period) {
viewCount = GM_getValue('viewCount');
} else {
GM_setValue('period', period);
GM_setValue('viewCount', 0);
viewCount = 0;
}
for(var i = 0; i < viewCount; i++) {
appendNoise(i);
}
setInterval(function() {
if (doing()) {
viewCount++;
GM_setValue('viewCount', viewCount);
appendNoise(viewCount);
}
}, 5000);
}
setup();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment