Skip to content

Instantly share code, notes, and snippets.

@hitode909
Created July 21, 2010 13:14
Show Gist options
  • Save hitode909/484467 to your computer and use it in GitHub Desktop.
Save hitode909/484467 to your computer and use it in GitHub Desktop.
はてブの非表示ユーザをlivedoor Readerでも非表示にする
// ==UserScript==
// @name ldr-hateb-ignore-users
// @namespace http://www.hatena.ne.jp/hitode909
// @include http://reader.livedoor.com/reader/
// @include http://fastladder.com/reader/
// ==/UserScript==
var IGNORE_USERS_RULE = '';
function get_ignore_users() {
var ignore_users_cache = eval(GM_getValue("ignore_users") || "null");
if (ignore_users_cache && ignore_users_cache.expire > Date.now()) {
IGNORE_USERS_RULE = ignore_users_cache.ignore_users;
return;
}
GM_xmlhttpRequest({
method: "GET",
url: "http://b.hatena.ne.jp/my/config",
onload: function(response) {
try {
var tmp = document.createElement('div');
tmp.innerHTML = response.responseText;
var ignore_users = tmp.querySelector('input[name="ignore_users"]').value;
GM_setValue("ignore_users", uneval({ignore_users: ignore_users, expire: Date.now() + 24 * 3600 * 1000}));
IGNORE_USERS_RULE = ignore_users;
} catch(e) {
console.log(e);
}
}
});
}
function reset() {
GM_deleteValue("ignore_users");
get_ignore_users();
}
function start() {
document.body.addEventListener('DOMNodeInserted',function(event){
var element = event.target;
if (element.className.match('item')
&& element.textContent.match(IGNORE_USERS_RULE)
|| Array.some(element.querySelectorAll('a'), function(a) { return a.href.match(IGNORE_USERS_RULE) })
) ng(element);
}, false);
}
function ng(element) {
if (element.nodeType == 3) {
element.textContent = element.textContent.replace(/\S/g, function(_) { return 'あ' });
}
if (element.childNodes) {
Array.forEach(element.childNodes, function(child) {
ng(child);
});
}
}
GM_registerMenuCommand('ldr hateb ignore users - clear cache', reset);
get_ignore_users();
start();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment