javascrtipt access to style sheets.
January 29, 2006 4:19 PM   Subscribe

javascript question: im looking for a way to access the style sheet text in firefox.

im looking for the full text - like with the comments and everything, not just the cssText attribute of each individual cssRule.

for an example, see the "Edit CSS" option in the developer plug in.

background information: im writting a greaseMonkey script that will allow you to view/edit the markup and css of a page you're viewing. In order to make the CSS editable, i need a way to quickly and easily grab the text from all the style sheets and move them into one style tag, then disable the originals. Ive got a working copy, except that i have to cycle through all the cssRules and grab the text of each and append it to the new style tag - which is slow, destroys the orginal formatting and leaves out any comments.
posted by Tryptophan-5ht to Computers & Internet (6 answers total)
 
Why can't you do what the developer extension does?

(And, askMefi is great for hard-to-categorize questions, but for specific questions like this, the Mozilla extension forum is going to provide you with a lot more eyes that know javascripting for Mozilla.)
posted by orthogonality at 4:49 PM on January 29, 2006


Response by poster: id like to do what the dev ext does, but i have no clue how. And yeah, the mozilla forums are prolly a better bet, but you're all such an intelligent diverse lot, i figured id give it a try.
posted by Tryptophan-5ht at 4:57 PM on January 29, 2006


I really don't mean this to be rude, but, why are you doing this?

There's already an extension which does this (and various others which do similar things), and you're aware of it. So what's the point? Why not create something new?
posted by AmbroseChapel at 5:15 PM on January 29, 2006


Response by poster: My question only pertained to one particular aspect of what im trying to do. I haven't seen one that will also allow you to modify the markup. ...just the CSS. unless there is one i don't know about?
posted by Tryptophan-5ht at 5:22 PM on January 29, 2006


Best answer: AmbroseChapel writes "So what's the point? "

He may want it as a component of some larger system.

As it happens, for an extension I wrote, I wanted to copy the HTML source for the selected text. There's code that already does this (long since folded into the trunk) but the code that does this didn't do it quite the way I needed it.

But by examining that existing code, I was able to figure out how it was done and re-do in exactly teh wayu I needed to.


Tryptophan-5ht writes "id like to do what the dev ext does, but i have no clue how. "

Have you tried reading the dev extension source code?
posted by orthogonality at 5:24 PM on January 29, 2006


Response by poster: "Have you tried reading the dev extension source code?"
didn't even occur to me. thats why i asked here :P
posted by Tryptophan-5ht at 5:41 PM on January 29, 2006


« Older Straight to video filter   |   I sell. He pays. He disappears. When can I keep... Newer »
This thread is closed to new comments.