summaryrefslogtreecommitdiff
path: root/static/userscripts/wordfilter.user.js
diff options
context:
space:
mode:
Diffstat (limited to 'static/userscripts/wordfilter.user.js')
-rw-r--r--static/userscripts/wordfilter.user.js29
1 files changed, 29 insertions, 0 deletions
diff --git a/static/userscripts/wordfilter.user.js b/static/userscripts/wordfilter.user.js
new file mode 100644
index 0000000..476706f
--- /dev/null
+++ b/static/userscripts/wordfilter.user.js
@@ -0,0 +1,29 @@
+// ==UserScript==
+// @name Word Filter for textboard.org
+// @namespace http://textboard.org
+// @description Replace words with other words
+// @version 1
+// @match *://textboard.org/*
+// @grant none
+// ==/UserScript==
+(function() {
+ 'use strict';
+ var replacements, regex, key, textnodes, node, s;
+ replacements = {
+ "nigger": "mujina",
+ "faggot": "baku",
+ };
+ regex = {};
+ for (key in replacements) {
+ regex[key] = new RegExp(key, 'gi');
+ }
+ textnodes = document.evaluate( "//body//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;
+ }
+})();