...

View Full Version : Greasemonkey script to change colors on a website with nested framesets.



Cleesh
03-29-2008, 04:19 AM
I've been trying to find out how to change the background color of a particular webpage by creating a Greasemonkey script (using Firefox here). The problems arise when apparently I need to target each frame individually. How do I refer to them? Being a noob to javascript (god, even that is an overstatement), I've tried gazillion different combinations of commands (code) to acheive this, so far I've had two kinds of results: only the first frame (named menupane) gets altered or nothing gets altered.

Here's the source code of the website:



<html>
<head><title>The Kingdom of Loathing</title>
</head>
<frameset id=rootset cols="4*,*">
<frameset id=menuset rows="50,*">
<frame name=menupane src="topmenu.php" scrolling=no></frame>
<frameset id=mainset cols="200,*">
<frame name=charpane src="charpane.php">
<frame name=mainpane src="main.php"></frame>
</frameset>
</frameset>
<frame name=chatpane src="chatlaunch.php"></frame>
</frameset>
</html>


(KoL, a whacky RPG, kingdomofloathing.com).
Anyway... this code only changes the frame named 'menupane'. Nothing else. I had the impression that 'window' was the topmost object and all frames are its obedient bit-- slaves. I guess not.


window.document.bgColor="black"



This piece of work (one of the thousands) I came up with changes absolutely nothing. Zip. Zero. Ever been that noob coder trying to figure out the correct order of things, or what is even remotely appropriate code with zero guidance?


window.frames['rootset'].frames['menuset'].frames['mainset'].frames['charpane'].document.bgColor="black"



Here are some things to be taken into consideration:
- No other Greasemonkey script can't conflict with this script since I've disabled them during the testing (got dozen other scripts to alter that website).
- I know about the feature in Firefox with which you can change the background and text color in ALL pages, but really, I just want to invert the colors on this one website, since too much white starts to hurt my eyes after a while. Google will be next. Are there any other options than Greasemonkey to acheive this kind of thing ("simple" change of colors on user's end)?

Has Googling for javascript tutorials been helpful? Yes, a little. Confusing? Twice so.

I just want the background to be black and text white/light grey... I'll figure out the colors once I can target the frames correctly.
Is there any other information I might provide that might be essential in troubleshooting this?
Thank you in advance.

shyam
03-29-2008, 07:22 PM
window.frames['rootset'].frames['menuset'].frames['mainset'].frames['charpane'].document.bgColor="black"



did u try


window.frames['charpane'].document.bgColor="black";

Cleesh
03-30-2008, 12:32 AM
I just did. Pretty sure that exact line was among one of the first attempts. I wish it worked, but it doesn't (no visible change). Also, Error Console (in Firefox: Tools -> Error Console) says

window.frames.charpane has no properties

It's always saying something similar. Bla bla has no properties, depending on the code that was attempted.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum