I want to use Greasemonkey to highlight two words e.g. "Basel, Bern". If I use only Basel the version below works. Not very well but well enough. But when I use two words the highlighting doesn't work.
// ==UserScript==
// @name highlight-some-words
// @description highlight some words in html
// @grant none
// ==/UserScript==
document.body.innerHTML= document.body.innerHTML.replace(/Basel|Bern/g, function(m){
return '<span style="background-color:lightgreen">'+m+'</span>'
});
EDIT: Interesting, the script works on stackoverflow.com but not google.com. Why? And how to modify the script then?
See Question&Answers more detail:os