Created
July 27, 2024 07:29
-
-
Save allyouaskfor/915966105842a16bdec0b8d89b27a08b to your computer and use it in GitHub Desktop.
Userscripts GM_addStyle fix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Example | |
// @supportURL https://stackoverflow.com/a/33176845/6369424 | |
// @description Fix GM_addStyle undefined. | |
// ==/UserScript== | |
function GM_addStyle(css) { | |
const style = document.getElementById("elytSdda_MG") || (function() { | |
const style = document.createElement('style'); | |
style.type = 'text/css'; | |
style.id = "elytSdda_MG"; | |
document.head.appendChild(style); | |
return style; | |
})(); | |
const sheet = style.sheet; | |
sheet.insertRule(css, (sheet.rules || sheet.cssRules || []).length); | |
} | |
GM_addStyle(` | |
p { color:red; } | |
`); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment