Click here to Skip to main content
15,891,567 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hey there!

I'm trying to make a chrome extension for the fun of it that replaces the words Package, Shipment, parcel and etc in our main language to the Meme Pakig: https://i.imgur.com/4HxWLpK.jpg[^]

With little to no coding experience. (I can make an html page that's it lmao)

From the tutorials that I have found I came up with some JS stuff

Sadly all I get are issues that makes EVERY WORDS PAKIG, I mean it's fun but uhh... that's not what I had in mind...

Tell me how I could improve that so I could say that I didn't effortlessly made some s*itposting and actually made something fun! :^p

Thanks!

What I have tried:

Content.js

var elements = document.getElementsByTagName('*');

for (var i = 0; i < elements.length; i++) {
    var element = elements[i];

    for (var j = 0; j < element.childNodes.length; j++) {
        var node = element.childNodes[j];

        if (node.nodeType === 3) {
            var text = node.nodeValue;
            var replacedText = text.replace(/[package|colis|parcel|packidj|shipment]/gi, '[pakig]');

            if (replacedText !== text) {
                element.replaceChild(document.createTextNode(replacedText), node);
            }
        }
    }
}


manifest.js

{
"manifest_version": 2,
    "name": "[The Pakig Maker]",
    "description": "[Replaces words like package, parcel and so on with the Pakig Meme, yes I really took time to make this.]",
    "version": "1.0",
    "content_scripts": [
        {
            "matches": [
                "*://*/*"
            ],
            "js": [
                "content.js"
            ],
            "run_at": "document_end"
        }
    ]
}
Posted
Updated 7-Mar-22 23:34pm

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900