Merge pull request #3792 from toofar/fix/gm_addstyle_earlyload

Greasemonkey: fix early GM_addStyle with fast sites.
Seems to be a working fix, despite noone having clarity on what is the ideal approach.
This commit is contained in:
toofar 2018-04-09 19:11:10 +12:00 committed by GitHub
commit 69d642cab8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -100,11 +100,8 @@
const head = document.getElementsByTagName("head")[0]; const head = document.getElementsByTagName("head")[0];
if (head === undefined) { if (head === undefined) {
document.onreadystatechange = function() { // no head yet, stick it whereever
if (document.readyState === "interactive") { document.documentElement.appendChild(oStyle);
document.getElementsByTagName("head")[0].appendChild(oStyle);
}
};
} else { } else {
head.appendChild(oStyle); head.appendChild(oStyle);
} }