Skip to content

Instantly share code, notes, and snippets.

@javascripter
Created March 17, 2009 04:03
Show Gist options
  • Save javascripter/80277 to your computer and use it in GitHub Desktop.
Save javascripter/80277 to your computer and use it in GitHub Desktop.
// ==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