Improved greasemonkey script by adding scope
This commit is contained in:
parent
e7e8269cbf
commit
6509400f8e
|
@ -1,33 +1,39 @@
|
||||||
// ==UserScript==
|
// ==UserScript==
|
||||||
// @name HeroSaver for HeroForge
|
// @name HeroSaver for HeroForge
|
||||||
// @version 1
|
// @version 1
|
||||||
|
// @description Automatically load HeroSaver when visiting HeroForge
|
||||||
// @namespace https://github.com/christofsteel/herosaver
|
// @namespace https://github.com/christofsteel/herosaver
|
||||||
// @match https://www.heroforge.com/
|
// @match https://www.heroforge.com/
|
||||||
|
// @grant none
|
||||||
// ==/UserScript==
|
// ==/UserScript==
|
||||||
|
|
||||||
var observerOptions = {
|
(function() {
|
||||||
childList: true,
|
'use strict';
|
||||||
subtree: true
|
|
||||||
}
|
|
||||||
|
|
||||||
var observer = new MutationObserver(function(mutationList, observer) {
|
var observerOptions = {
|
||||||
mutationList.forEach((mutation) => {
|
childList: true,
|
||||||
if (Array.from(mutation.removedNodes).some((element) => {
|
subtree: true
|
||||||
return element.className === "loadingScreen";
|
}
|
||||||
})) {
|
|
||||||
observer.disconnect();
|
var observer = new MutationObserver(function(mutationList, observer) {
|
||||||
var xhr=new XMLHttpRequest;
|
mutationList.forEach((mutation) => {
|
||||||
xhr.open("get","https://raw.githubusercontent.com/christofsteel/herosaver/master/herosaver.min.js",true);
|
if (Array.from(mutation.removedNodes).some((element) => {
|
||||||
xhr.onreadystatechange=function(){
|
return element.className === "loadingScreen";
|
||||||
if (xhr.readyState == 4) {
|
})) {
|
||||||
var script=document.createElement("script");
|
observer.disconnect();
|
||||||
script.type="text/javascript";
|
var xhr=new XMLHttpRequest;
|
||||||
script.text=xhr.responseText;
|
xhr.open("get","https://raw.githubusercontent.com/christofsteel/herosaver/master/herosaver.min.js",true);
|
||||||
document.body.appendChild(script)
|
xhr.onreadystatechange=function(){
|
||||||
}
|
if (xhr.readyState == 4) {
|
||||||
};
|
var script=document.createElement("script");
|
||||||
xhr.send(null);
|
script.type="text/javascript";
|
||||||
}
|
script.text=xhr.responseText;
|
||||||
|
document.body.appendChild(script)
|
||||||
|
}
|
||||||
|
};
|
||||||
|
xhr.send(null);
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
observer.observe(document.querySelector("body"), observerOptions);
|
||||||
observer.observe(document.querySelector("body"), observerOptions);
|
})();
|
||||||
|
|
Loading…
Reference in New Issue