Political statements aside, this was a fun project that put my JS skills to test.
This extension is available for install on the Chrome store, and has gotten quite a few downloads due to its popularity on social media.
This was a bit trickier to accomplish than I'd thought, as the code has to work on all pages, including pages like google search results. I wrote some code that seemed to work, but I soon found out that it interrupted YouTube and other web apps as it was stripping pages of eventListeners - not ideal!
The easy part was selecting all the elements, turning it into an array (using the ES6 spread method) and running a forEach to look through every element. What wasn't instantly obvious was that I had to run another forEach method nested within the first one to look through all the child nodes as the first loop was only running on the outside of the elements, not the children of the elements. Another learning was the use of the nodeType property to find out the type of data it contained (a nodeType of 3 indicates text).
I separated out the text replacement as its own separate function so I (or somebody else for that matter) could customise the code easily to replace other words and phrases.
I should mention that I also learned how Chrome extensions work, and I plan to use this to strip existing styling, and insert my own stylings for specific selected domains.
Here is a collection of website components from popular websites written from scratch.