[Greasemonkey] Grab text string in TD

Edward Lee edilee at gmail.com
Fri Apr 22 13:08:08 EDT 2005


On 4/22/05, Scott R. Turner <srt at aero.org> wrote:
> If doing search-and-replace is fairly simple (the suggestions so far
> don't work for me, but that might be my fault) then I agree.

Does this not work for you?

(function() {
with (document.documentElement) {
 innerHTML = innerHTML.replace(/Google/g, 'Gooooogle!');
}
}) ();

Go to google main page and it'll change stuff to Gooooogle! Search,
About Gooooogle!, (C) Goooogle!... it should change the title as well,
but apparently updating innerHTML doesn't update title (gecko bug?).
Also FAYT does not match anything at all after replacing innerHTML.
However, if instead of using "with (document.documentElement)" you use
"with (document.body)", FAYT works fine.


I also agree with the GM_functions providing functionality that normal
page javascripts cannot do by themselves. GM_self is kinda borderline
because the script can find its own innerHTML when searching through
script tags, but it would be even more hack-y identifying if you're in
the correct script block.
-- 
Ed


More information about the Greasemonkey mailing list