Skip to content

Instantly share code, notes, and snippets.

@arantius
Last active November 7, 2023 00:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arantius/e50990f74376f4ed906243af392d6038 to your computer and use it in GitHub Desktop.
Save arantius/e50990f74376f4ed906243af392d6038 to your computer and use it in GitHub Desktop.
Test script with a CSS resource
// ==UserScript==
// @name CSS Resource Test
// @version 1
// @grant GM.getResourceUrl
// @resource css test.css
// ==/UserScript==
(async function() {
var link = document.createElement('link');
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = await GM.getResourceUrl('css', 'text/css');
link.media = 'all';
(document.head || document.body).appendChild(link);
})();
body { outline: 1px dashed red; }
@arantius
Copy link
Author

arantius commented Nov 6, 2023

Ooof.

The stylesheet blob:http://example.org/db005dad-89f3-4bf3-869d-1a07cafc0ea2 was not loaded because its MIME type, “text/plain”, is not “text/css”.

This depends on the page! On some pages it works, on some pages they do something to make this strict.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment