Not work in xhtml, breaks svg/xml
Closed this issue · 8 comments
- The script does not work in xhtml, as xhtml tag is case sensitive. The script will not work if the tag is in lowercase or mixed case
- this script breaks xml viewer of firefox due to it inject style tag into xml without validate whether it is a xhtml / has xlt first. which force the firefox to fallback the rendering to xhtml mode because it have style.
- this script also pollutes svg/xml saved by
open the svg and right click save as
for the same reason as point 2
Do you have any URL to reproduce the issue? Which script manager you are using? Maybe we should ask them to support injecting styles to XHTML/XML pages by using GM_addStyle
.
https://www.w3schools.com/xml/note.xml
problably any xml without style
open this, you should see the style injected display as text on it (I am using tamparmonkey)
The style injection actully works, the problem is it should not inejct to there as the xml here is not intended to displayed as xhtml.
https://www.w3.org/2000/07/8378/xhtml2/spec-examples/ xhtml example
pick any link element to console and get tagName
, they are all lower case, so element.tagName === "A"
won't work
I personally just skip xml if it does not have any stylesheet existed at all, but maybe there is a better way to differ those xmls that not intended to view dirrectly by human from those which are xhtml.
if (document.contentType.match(/\/xml$/) && document.styleSheets.length === 0) {
console.info('Stopped this script because it is a xml!');
// stop as it is possibly a xml
return;
}
See also Tampermonkey/tampermonkey#639.
Does it break SVG?
It cause all svg download with open and right click to have that line, no visual problem though
Very interesting. https://bugzilla.mozilla.org/show_bug.cgi?id=1522047
It seems that Firefox behaves differently when you save the image with different types: https://bugzilla.mozilla.org/show_bug.cgi?id=1522047#c5.
To save the original SVG file, you have to
select "Web page, SVG only" in the 'save as' dialog 'type' dropdown