summaryrefslogtreecommitdiff
path: root/static/userscripts/wordfilter.user.js
blob: 476706f68993099c7612368740a2abe86b56d0bc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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;
  }
})();