-1

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?

1 Answers1

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