Created
March 17, 2009 04:03
-
-
Save javascripter/80277 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 NoSearchable | |
// // @namespace http://d.hatena.ne.jp/javascripter/ | |
// // @include http* | |
// // ==/UserScript== | |
function noSearchable(sentence) { | |
var inconspicuous = "./ ,_-~?+"; | |
return sentence.replace( | |
/[一-龠]/g, | |
function (m) { | |
return m + inconspicuous.charAt( | |
Math.floor(inconspicuous.length * Math.random()) | |
); | |
} | |
); | |
} | |
function insert(node) { | |
var p = node.ownerDocument.evaluate( | |
"descendant-or-self::text()", | |
node, | |
null, | |
XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, | |
null | |
), t, i; | |
for (i = 0; i < p.snapshotLength; ++i) { | |
t = p.snapshotItem(i); | |
t.nodeValue = noSearchable(t.nodeValue); | |
} | |
} | |
insert(document.body); | |
document.addEventListener( | |
"DOMNodeInserted", | |
function (e) { | |
insert(e.target); | |
}, | |
false | |
); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment