[Greasemonkey] Stripping font tags
Charles Iliya Krempeaux
supercanadian at gmail.com
Thu Dec 1 10:01:44 EST 2005
Hello,
On 11/30/05, Randy Burke <uncle.ranny at gmail.com> wrote:
> I have an internal work page that i want to skin, the big problem that I am
> having is that it was wrote with a bad mix of CSS and font tags.
>
> I was just wondering if there is a easy way to strip all the font tags out
> of the page
(Don't know if this code works,... I just quickly wrote it... but....)
Maybe you could find all the <font> elements with:
var font_elements = document.getElementsByTagName("font");
And then iterate though them all and replace the <font> with a <span>.
Maybe with something like:
if ( font_elements && font_elements.length ) {
for (var i = font_elements.length-1; i>-1; i--) {
// Create a <span> that we can use to replace the <form>.
// (Probably should check for errors, but don't here.)
var span_element = document.createElement("span");
var font_element = font_elements[i];
// There's a race condition here. (Should probably do
this in a better way.)
span_element.innerHTML = font_element.innerHTML;
// Get the parent.
// (Probably should check for errors, but don't here.)
var parent = font_element.parentNode;
parent.replaceChild(span_element, font_element);
} // for
}
--
Charles Iliya Krempeaux, B.Sc.
charles @ reptile.ca
supercanadian @ gmail.com
developer weblog: http://ChangeLog.ca/
___________________________________________________________________________
Never forget where you came from
More information about the Greasemonkey
mailing list