[Greasemonkey] Changing HMTLTitleElement

jason brackins j-san at j-san.net
Mon Apr 25 15:19:37 EDT 2005

Hi all,

I am trying to change the title of the page my script is running in. The 
page in question is a wiki and it puts the least specific info first in 
the title element. So you might have "Wiki Site Name - Current Page 
name" as the title. Since I tend to have 10-15 tabs opened when I'm 
using this particular wiki it would be really nice to swap the two parts.

It's easy to do if you just want the change reflected in the DOM (as 
viewed with the DOM inspector). But the change never makes it to the 
title bar of the window (and therefor not the tab label).

I'm not sure if what I'm trying to do is even possible. After all, the 
label on the window picks up the Title element and sets itself long 
before the page finishes loading. Since the window label is outside of 
the DOM the javascript can't get to it directly. I was hoping Firefox 
would notice the change in the DOM and react accordingly, but no joy. 
Anybody have any ideas?

btw, using FF 1.0.3, Greasemonkey 0.2.6, windows 98

my code looks like this:

function changeTitle() {
var ptitle = document.getElementsByTagName("title")[0];
    var titleComponents = ptitle.innerHTML.split(' - ');
    ptitle.textContent = titleComponents[1]+' - '+titleComponents[0];   
Jason Brackins
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mozdev.org/pipermail/greasemonkey/attachments/20050425/63597d70/attachment.htm

More information about the Greasemonkey mailing list