User:Chrissy/projects/Trump=Turd

From XPUB & Lens-Based wiki

Description

Firefox Extension to exchange specific words in browser.

on the base of Josephs's Extension I asked for an easy script to change specific words into other words. In this example on every webpage the Word "Trump" to "Turd".

Turd-icon.png

preview


Code

manifest.json

{
    "manifest_version": 3,
    "name": "xyz",
    "version": "1.0",
    "permissions": [
        "activeTab",
        "storage",
        "scripting"
    ],
    "description": "make the internet great again",
    "content_scripts": [
        {
            "matches": [
                "*://*/*"
            ],
            "js": [
                "extra.js"
            ]
        }
    ],
    "icons": {
        "48": "turd-icon.png"
    }
}

javascript

console.log("hello worldldskdsklmdfklds");

var elements = document.body.getElementsByTagName("*");
console.log(elements);

for (var counter = 0; counter < elements.length; counter++) {
    var text = elements[counter].innerHTML;
    if (text && text.includes("Trump")) {
        console.log("Trump found");

        elements[counter].innerHTML = text.replace("Trump", "Turd");

    }

    if (text && text.includes("TRUMP")) {
        console.log("Turd found");

        elements[counter].innerHTML = text.replace("TRUMP", "Turd");


    }
}