You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@filetype: @mimetype would be good too text/html: text/plain would be good too
About
This is a request to add new API to GM.xmlHttpRequest, or to the core of the Greasemonkey extension, that can influence a change in document.contentType.
Preface
I have wrote a userscript that converts structured data files (i.e. XML and JSON) into human readable HTML files.
Overhaul, the program works as expected; documents are processed and forged successfully into HTML.
All the extra functionalities work well when document.contentType (read only) does not contain xml.
However, when document.contentType has xml, any code that contains querySelector would fail because the document is believed to be whatever document.contentType has determined upon initial request (an XML file), and, apparently, the web browser doesn't check document once it has been loaded.
An error message from the program suggests the file processed is XML when in reality it is an HTML, hence hinders other functions to be executed:
Expected Behavior
Execute actions on document as as HTML.
Actual Behavior
Browser blocks HTML actions (throws errors) because it is believed to be an XML.
This is an interesting script, I looked at Tampermonkey and Violentmonkey, it seems to be working, but Scriptcat is not working, let me first solve this problem 😂.
In addition, can we solve this problem from other aspects? For example, Web Component, the style of this attribute will inherit from custom-card, but this seems troublesome
I looked at Tampermonkey and Violentmonkey, it seems to be working, but Scriptcat is not working, let me first solve this problem 😂.
It doesn't work with Greasemonkey neither.
I think it stopped to work with Greasemonkey after I've added more GM.getValue and GM.setValue.
In addition, can we solve this problem from other aspects? For example, Web Component, the style of this attribute will inherit from custom-card, but this seems troublesome
I'm an Attorney at Law, not a programmer.
Please kindly explain what do you mean by "Web Component".
As I stated, I think that a metablock (@filetype or @mimetype) that would imitate "Open in Browser" should handle this task, not only for XML files, but also images archives and documents.
This is the document of Web Component: https://developer.mozilla.org/en-US/docs/Web/API/Web_components, my idea is to use its shadow DOM feature to change the outer custom-card style Inheritance, but I'm not sure if I can solve this problem, and it's very troublesome.
What's weird is that some elements have element.style and some don't.
In short, see if there is any other solution to this problem. If not, I will consider trying to add the metablock @filetype you mentioned (but maybe in this form: #54)
I have managed to overcome this setback, namely by passing the HTML element newDocument and processing it in all ways feasible (see preProcess) and then replacing document by newDocument. See v24.04.06 vs. v24.04.08.
There was also another matter which required to create an element and change CSS Stylesheet in order to get the expected behaviour, because JavaScript attribute style does not work with document.contentType that ends with XML. See v24.04.08 vs. v24.04.09.
The only functionality which remains not to work upon XML is mode switcher (bright and dark) due to attribute style, yet it might be possible to fix.
Activity
[-]Add an equivalent to webRequest.onHeadersReceived[/-][+]New metablock @filetype[/+]CodFrm commentedon Jun 29, 2023
This is an interesting script, I looked at Tampermonkey and Violentmonkey, it seems to be working, but Scriptcat is not working, let me first solve this problem 😂.
In addition, can we solve this problem from other aspects? For example, Web Component, the style of this attribute will inherit from custom-card, but this seems troublesome
sjehuda commentedon Jun 29, 2023
Thank you.
It doesn't work with Greasemonkey neither.
I think it stopped to work with Greasemonkey after I've added more
GM.getValueandGM.setValue.I'm an Attorney at Law, not a programmer.
Please kindly explain what do you mean by "Web Component".
As I stated, I think that a metablock (
@filetypeor@mimetype) that would imitate "Open in Browser" should handle this task, not only for XML files, but also images archives and documents.See my comments at violentmonkey/violentmonkey#1842 (comment)
sjehuda commentedon Jun 29, 2023
Please navigate to
about:configSet
devtools.jsonview.enabledtofalseAnd test this script with these pages:
https://www.jsonfeed.org/feed.json
https://nu.federati.net/api/statuses/user_timeline/2.as
http://scripting.com/rss.json
https://peertube.su/feeds/videos.json?sort=-trending
https://librivox.org/feed/
Video preview of the script in action in a page that
document.contentTypedoesn't containxml.simplescreenrecorder-2023-06-29_21.12.45.mp4
CodFrm commentedon Jun 30, 2023
This is the document of Web Component: https://developer.mozilla.org/en-US/docs/Web/API/Web_components, my idea is to use its shadow DOM feature to change the outer
custom-cardstyle Inheritance, but I'm not sure if I can solve this problem, and it's very troublesome.What's weird is that some elements have
element.styleand some don't.In short, see if there is any other solution to this problem. If not, I will consider trying to add the metablock @filetype you mentioned (but maybe in this form: #54)
🐛 修复xml文档无法加载脚本的问题 #211
sjehuda commentedon Apr 8, 2024
I have managed to overcome this setback, namely by passing the HTML element
newDocumentand processing it in all ways feasible (seepreProcess) and then replacingdocumentbynewDocument. See v24.04.06 vs. v24.04.08.There was also another matter which required to create an element and change CSS Stylesheet in order to get the expected behaviour, because JavaScript attribute
styledoes not work withdocument.contentTypethat ends with XML. See v24.04.08 vs. v24.04.09.The only functionality which remains not to work upon XML is mode switcher (bright and dark) due to attribute
style, yet it might be possible to fix.