Currently, I can either replace a resource loaded from an URL, or I can add a script or stylesheet from the editor. I would love to add scripts or stylesheets (<script> or <link> tags) from an URL though (so that e.g. CSS @import etc is also working fine), effectively an "Inject resource from URL" rule (as oposed to "Inject File", which might make more sense to call "Inject custom resource" then).
Maybe URLs starting with file:// could be included as plain text again, but otherwise a <script src="SPECIFIED URL"></script> is totally enough.
An alternative would be to allow "File Type: HTML" for "Inject File", so I can add stuff like <script src="..."></script> to the <head>.
A workaround is to add a Inject File with "File Type: JavaScript", with the following content:
[
{ tag: "script", src: "..." },
{ tag: "link", rel: "stylesheet", href: "..." }
].forEach(def => {
const el = document.createElement(def.tag);
for (let attr in def) if (attr != "tag") el.setAttribute(attr, def[attr]);
document.currentScript.parentElement.appendChild(el);
});
Currently, I can either replace a resource loaded from an URL, or I can add a script or stylesheet from the editor. I would love to add scripts or stylesheets (
<script>
or<link>
tags) from an URL though (so that e.g. CSS @import etc is also working fine), effectively an "Inject resource from URL" rule (as oposed to "Inject File", which might make more sense to call "Inject custom resource" then).Maybe URLs starting with
file://
could be included as plain text again, but otherwise a<script src="SPECIFIED URL"></script>
is totally enough.An alternative would be to allow "File Type: HTML" for "Inject File", so I can add stuff like
<script src="..."></script>
to the<head>
.A workaround is to add a
Inject File
with "File Type: JavaScript", with the following content: