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) Closed 2 years ago . 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. 回答1: This script iterates through each element in the document and replaces