forked from dserhienko/StlSaver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
greasemonkey_autoload.user.js
39 lines (36 loc) · 1.34 KB
/
greasemonkey_autoload.user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// ==UserScript==
// @name HeroSaver for HeroForge
// @version 1
// @description Automatically load HeroSaver when visiting HeroForge
// @namespace https://github.com/christofsteel/herosaver
// @match https://www.heroforge.com/
// @grant none
// ==/UserScript==
(function() {
'use strict';
var observerOptions = {
childList: true,
subtree: true
}
var observer = new MutationObserver(function(mutationList, observer) {
mutationList.forEach((mutation) => {
if (Array.from(mutation.removedNodes).some((element) => {
return element.className === "loadingScreen";
})) {
observer.disconnect();
var xhr=new XMLHttpRequest;
xhr.open("get","https://raw.githubusercontent.com/fingin/stlsaver/master/herosaver.js",true);
xhr.onreadystatechange=function(){
if (xhr.readyState == 4) {
var script=document.createElement("script");
script.type="text/javascript";
script.text=xhr.responseText;
document.body.appendChild(script)
}
};
xhr.send(null);
}
});
});
observer.observe(document.querySelector("body"), observerOptions);
})();