Pastebin launched a little side project called HostCabi.net, check it out ;-)Don't like ads? PRO users don't see any ads ;-)
Guest

Reveal the Patriarchy userscript

By: Evilagram on Dec 3rd, 2013  |  syntax: JavaScript  |  size: 1.74 KB  |  hits: 97  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. // Reveal the Patriarchy
  2. // version 1.0
  3. // 2013-12-03
  4. // Copyright 2013, Chris Wagar
  5. //
  6. // This program is free software; you can redistribute it and/or modify
  7. // it under the terms of the GNU General Public License as published by
  8. // the Free Software Foundation; either version 2 of the License, or
  9. // (at your option) any later version.
  10. //
  11. // This program is distributed in the hope that it will be useful,
  12. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. // GNU General Public License for more details:
  15. // <http://www.gnu.org/licenses/gpl.txt>
  16. //
  17. // Revision history:
  18. // 1.0  2013-12-03 initial version, based on:
  19. //      http://userscripts.org/scripts/show/5625
  20. //
  21. // ==UserScript==
  22. // @name          Reveal the Patriarchy
  23. // @namespace     Reveal Da Patriarchy la-li-lu-le-lo
  24. // @description   Replace all mentions of the Patriarchy with La-Li-Lu-Le-Lo
  25. // @include       *
  26. // @grant         none
  27. // ==/UserScript==
  28. //
  29. // --------------------------------------------------------------------
  30.  
  31. var replacements, regex, key, textnodes, node, s;
  32.  
  33. replacements = {
  34.         " patriarchy([ ,.?!])": " la-li-lu-le-lo$1",
  35.     " Patriarchy([ ,.?!])": " La-Li-Lu-Le-Lo$1",
  36.     " PATRIARCHY([ ,.?!])": " LA-LI-LU-LE-LO$1"
  37. };
  38.  
  39. regex = {};
  40. for (key in replacements) {
  41.     regex[key] = new RegExp(key, 'g');
  42. }
  43.  
  44. textnodes = document.evaluate(
  45.     "//text()",
  46.     document,
  47.     null,
  48.     XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,
  49.     null);
  50.  
  51. for (var i = 0; i < textnodes.snapshotLength; i++) {
  52.        
  53.         node = textnodes.snapshotItem(i);
  54.         s = node.data;
  55.        
  56.         for (key in replacements) {
  57.                 s = s.replace(regex[key], replacements[key]);
  58.         }
  59.  
  60.         node.data = s;
  61.  
  62. } // for