I want to make a bookmark that when I click it in my Favourites bar, a window.confirm will appear asking a question and if I click ok instead of cancel, it will go through the current website and look for a certain word (such as dog) which I can customize to be whatever I want. Then it will change every one of that word, into a different one (such as cat). Would anyone know a javascript for this?
Asked
Active
Viewed 472 times
-1
-
Why not just use a plugin like [https://addons.mozilla.org/da/firefox/addon/foxreplace/](https://addons.mozilla.org/da/firefox/addon/foxreplace/) for this? – Emil S. Jørgensen Jun 02 '16 at 12:02
-
I am using an iPad though. I Don't think that works on mobile devices – 2345678546 Jun 02 '16 at 12:07
1 Answers
1
make a bookingmark with the url pointing to:
javascript:(function () {
var rep = prompt('replace');
var wit = prompt('with');
if (confirm('replace ' + rep + ' with ' + wit + '?')) {
document.body.innerHTML = document.body.innerHTML.replace(new RegExp(rep, 'g'), wit);
}
}) ();

Emil S. Jørgensen
- 6,216
- 1
- 15
- 28
-
I copied that exact thing into bookmarks and it only replaced it with 'wit' every time even if I told it to replace it with something else – 2345678546 Jun 02 '16 at 12:21