User:Chrissy/projects/Trump=Turd: Difference between revisions
< User:Chrissy | projects
(Created page with "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".") |
No edit summary |
||
Line 1: | Line 1: | ||
on the base of Josephs's Extension I asked for an easy script to change specific words into other words. | ==Description== | ||
In this example on every webpage the Word "Trump" to "Turd". | '''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". | |||
==preview== | |||
{{#Widget:Video|mp4=https://pzwiki.wdka.nl/https://pzwiki.wdka.nl/mediadesign/File:Trump%3DTurd.mp4|style=height:200px;float:right;}} | |||
==Code== | |||
===manifest.json=== | |||
<syntaxhighlight> | |||
{ | |||
"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" | |||
} | |||
} | |||
</syntaxhighlight> | |||
===javascript=== | |||
<syntaxhighlight> | |||
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"); | |||
} | |||
} | |||
</syntaxhighlight> |
Revision as of 14:16, 20 March 2025
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".
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");
}
}