Find and replace in a webpage using javascript [duplicate]
This question already has an answer here: Replace many text terms, using Tampermonkey, without affecting URLs and not looking for classes or ids 1 answer What I want to do is replace all instances of 'foo' in a webpage with 'bar' in a JS bookmarklet/greasemonkey script. How can I do this? I suppose jQuery works, as there're hacks to include those in both bookmarklets and greasemonkey scripts. Josh Stodola This script iterates through each element in the document and replaces every instance of foo with bar . The gi modifiers on the regex make it do a global , case-insensitive search. var els =