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
I can grab a CSS or HTML file containing inline styles or style tags from anywhere, in any manner, and inject it on the page.
Actual Behavior
Script breaks.
Script
// ==UserScript==// @name ddd// @namespace// @description// @version 74// @author// @include *// @grant GM_getResourceText// @grant GM.xmlHttpRequest// @run-at document-end// @connect *// @resource css https://domain.com/cs.css// ==/UserScript==//Method 1 using GM_getResourceTextconstcontainer=document.createElement('div');// Attach a Shadow DOM to the containerconstshadowRoot=container.attachShadow({mode: 'open'});// Create a <style> element and inject the fetched CSS into itconststyle=document.createElement('style');style.textContent=GM_getResourceText("css");// Inject the CSS content// Append the style element to the Shadow DOMshadowRoot.appendChild(style);// Append the container (with Shadow DOM) to the bodydocument.body.appendChild(container);//Method 2 using "fetch"// Request the external CSSGM.xmlHttpRequest({method: 'GET',url: 'https://domain.com/cs.css',// Replace with your CSS URLonload: function(response){// Create a container for the Shadow DOMconstcontainer=document.createElement('div');// Attach a Shadow DOM to the containerconstshadowRoot=container.attachShadow({mode: 'open'});// Create a <style> element and inject the fetched CSS into itconststyle=document.createElement('style');style.textContent=response.responseText;// Inject the CSS content// Append the style element to the Shadow DOMshadowRoot.appendChild(style);// Append the container (with Shadow DOM) to the bodydocument.body.appendChild(container);}});
Expected Behavior
I can grab a CSS or HTML file containing inline styles or style tags from anywhere, in any manner, and inject it on the page.
Actual Behavior
Script breaks.
Script
Testing page
https://www.icloud.com/shortcuts/7d4712f9ca6e4c60aeb5cf813873dcd3
The text was updated successfully, but these errors were encountered: