Skip to content

Instantly share code, notes, and snippets.

@moklick
Created January 2, 2018 23:06
Show Gist options
  • Select an option

  • Save moklick/a7ad3a6caeb6d01fb0fa7da375f26eb2 to your computer and use it in GitHub Desktop.

Select an option

Save moklick/a7ad3a6caeb6d01fb0fa7da375f26eb2 to your computer and use it in GitHub Desktop.

Revisions

  1. moklick created this gist Jan 2, 2018.
    14 changes: 14 additions & 0 deletions content.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    // via http://stackoverflow.com/questions/10730309/find-all-text-nodes-in-html-page#answer-10730777
    function findTextNodes(el) {
    var node;
    var textNodes = [];
    var walk = document.createTreeWalker(el, NodeFilter.SHOW_TEXT, null, false);
    while (node = walk.nextNode()) {
    textNodes.push(node);
    }
    return textNodes;
    }

    findTextNodes(document.body).forEach(function(e) {
    e.textContent = e.textContent.replace(/\be(in|ine|inen|iner|inem)\b/gi, '1');
    });