Skip to content

Instantly share code, notes, and snippets.

@yigitbey
Last active February 12, 2018 18:41
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 yigitbey/54195aa12ddcc557f9a5 to your computer and use it in GitHub Desktop.
Save yigitbey/54195aa12ddcc557f9a5 to your computer and use it in GitHub Desktop.
Replaces Aynen to Evet.
// ==UserScript==
// @name Aynen Filter
// @namespace
// @description Replaces Aynen
// @include *
// @match *://*/*
// ==/UserScript==
document.body.addEventListener("DOMSubtreeModified", change, false);
change();
function change(){
var replacements, regex, textnodes, key, node, s;
replacements = {
"Aynen":"Evet",
"aynen":"evet",
};
regex = {};
for (key in replacements) {
regex[key] = new RegExp(key, 'g');
}
textnodes = document.evaluate(
"//text()",
document,
null,
XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,
null
);
for (var i = 0; i < textnodes.snapshotLength; i++) {
node = textnodes.snapshotItem(i);
s = node.data;
for (key in replacements) {
s = s.replace(regex[key], replacements[key]);
}
node.data = s;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment