From a6a0ea9ea258b5a4a833247b8d9d5f61e62f248d Mon Sep 17 00:00:00 2001 From: Nishanth Vijayan Date: Wed, 2 Mar 2016 23:52:06 +0530 Subject: [PATCH] Replace innerHTML method with the ugly code because of security requirements.See: https://developer.mozilla.org/en-US/Add-ons/Overlay_Extensions/XUL_School/DOM_Building_and_HTML_Insertion --- data/replacer.js | 5 ++++- package.json | 6 +++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/data/replacer.js b/data/replacer.js index ecddf9d..5577227 100644 --- a/data/replacer.js +++ b/data/replacer.js @@ -1 +1,4 @@ -document.body.innerHTML = document.body.innerHTML.replace(/trump/g, 'drumpf').replace(/Trump/g, 'Drumpf'); \ No newline at end of file +var textNode, walk=document.createTreeWalker(document,NodeFilter.SHOW_TEXT,null,false); +while(textNode=walk.nextNode()) { + textNode.nodeValue = textNode.nodeValue.replace(/trump/g, 'drumpf').replace(/Trump/g, 'Drumpf'); +} \ No newline at end of file diff --git a/package.json b/package.json index f0082c3..bc15b79 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { - "title": "Drumpfinator", - "name": "Drumpfinator", - "version": "0.0.1", + "title": "Drumpfinator Make Trump Drumpf Again", + "name": "drumpfinator_trump", + "version": "0.0.2", "description": "Add this to your browser and replace all instances of Trump with Drumpf.", "main": "index.js", "author": "Nishanth Vijayan",