[Greasemonkey] Stripping font tags
chris feldmann
cfeldmann at gmail.com
Sun Dec 4 15:16:27 EST 2005
On 12/1/05, Aaron Boodman <zboogs at gmail.com> wrote:
> Sure. Untested:
>
> var fontTag;
> var parent;
> var marker;
>
> // for each font tag
> while (fontTag = document.getElementsByTagName("font")[0]) {
> parent = fontTag.parentNode;
> marker = fontTag.nextSibling;
>
> // move the font tag's child nodes up into the parent in the right place
> while (fontTag.firstChild) {
> parent.insertBefore(fontTag.firstChild, marker);
> }
>
> // remove the font tag, now that it's empty
> parent.removeChild(fontTag);
> }
>
> - a
Not only more elegant than mine, this gets ALL the children of the
tag, stacking them up behind the next node, while mine assumed a
single child.
More information about the Greasemonkey
mailing list