kaspars.rinkevics / Bumbumbum

// ==UserScript==
// @name Bumbumbum
// @namespace Violentmonkey Scripts
// @match *://*/*
// @grant none
// @license MIT
// ==/UserScript==


(function() {
  var replacements, regex, key, textnodes, node, s; 

  replacements = { 
    
    "ministrs": "bumbulītis",
    "ministram": "bumbulītim",
    "ministra": "bumbulīša",
    "ministru": "bumbulīti",
    "Ministrs": "Bumbulītis",
    "Ministram": "Bumbulītim",
    "Ministra": "Bumbulīša",
    "Ministru": "Bumbulīti",
    };

regex = {}; 
for (key in replacements) { 
    regex[key] = new RegExp(key, 'g'); 
}

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; 
  
    console.log(s)
  
    for (key in replacements) { 
        s = s.replace(regex[key], replacements[key]); 
    } 
    node.data = s; 
} 

})();