Created
September 3, 2009 01:33
-
-
Save azu/180072 to your computer and use it in GitHub Desktop.
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 censored | |
// @namespace http://efcl.info/ | |
// @include http://favotter.matope.com/* | |
// ==/UserScript== | |
var _doc = document; | |
var replaceLists = { | |
"<censored>" : "お母さん", | |
"<censored>" : "お母さん", | |
} | |
var init = function (doc){ | |
var txt = xpath(doc , 'descendant::text()[string-length(normalize-space(self::text())) > 0 and not(ancestor::textarea) and not(ancestor::script) and not(ancestor::style)]'); | |
for(var i=0,tl=txt.snapshotLength; i<tl; ++i){ | |
var df,item = txt.snapshotItem(i), | |
text = item.nodeValue.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>'), | |
parent = item.parentNode, range = document.createRange(); | |
for (var j in replaceLists){ | |
text = text.replace(j,function(p){ | |
return replaceLists[j]; | |
}); | |
} | |
var newText = text; | |
range.selectNode(item); | |
df = range.createContextualFragment(newText); | |
parent.replaceChild(df, item); | |
range.detach(); | |
} | |
} | |
init(_doc); | |
function xpath(context, query){ | |
return _doc.evaluate( | |
query, context, null, | |
XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null | |
) | |
} | |
if(window.AutoPagerize) { | |
addFilterHandler(); | |
}else{ | |
window.addEventListener('GM_AutoPagerizeLoaded',boot,false); | |
} | |
function addFilterHandler(){ | |
window.AutoPagerize.addFilter(function(docs){ | |
docs.forEach(init); | |
}); | |
} | |
function e(id) { | |
return _doc.getElementById(id); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment