This commit is contained in:
parent
3814ebdcff
commit
41c0ea464e
1 changed files with 23 additions and 1 deletions
|
@ -14,7 +14,26 @@
|
||||||
// @require https://github.com/pie6k/jquery.initialize/raw/refs/heads/master/jquery.initialize.min.js
|
// @require https://github.com/pie6k/jquery.initialize/raw/refs/heads/master/jquery.initialize.min.js
|
||||||
// @run-at document-end
|
// @run-at document-end
|
||||||
// ==/UserScript==
|
// ==/UserScript==
|
||||||
|
function waitForElm(selector) {
|
||||||
|
return new Promise(resolve => {
|
||||||
|
if (document.querySelector(selector)) {
|
||||||
|
return resolve(document.querySelector(selector));
|
||||||
|
}
|
||||||
|
|
||||||
|
const observer = new MutationObserver(mutations => {
|
||||||
|
if (document.querySelector(selector)) {
|
||||||
|
observer.disconnect();
|
||||||
|
resolve(document.querySelector(selector));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// If you get "parameter 1 is not of type 'Node'" error, see https://stackoverflow.com/a/77855838/492336
|
||||||
|
observer.observe(document.body, {
|
||||||
|
childList: true,
|
||||||
|
subtree: true
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
let settings_HTML = `
|
let settings_HTML = `
|
||||||
<p>If you see this text, the userscript successfully rendered the settings page.</p>
|
<p>If you see this text, the userscript successfully rendered the settings page.</p>
|
||||||
`;
|
`;
|
||||||
|
@ -42,7 +61,10 @@ if (location.host == "www.guilded.gg") {
|
||||||
console.info("Guilded.GG detected.");
|
console.info("Guilded.GG detected.");
|
||||||
$.initialize('.DesktopOptionsControl-persistent-menu', function() {
|
$.initialize('.DesktopOptionsControl-persistent-menu', function() {
|
||||||
console.info("Settings opened!")
|
console.info("Settings opened!")
|
||||||
$(this).innerHTML += settings_entry;
|
waitForElm('.PersistentActionMenuSection-container').then((elm) => {
|
||||||
|
console.log('Injecting Builded settings...');
|
||||||
|
$(this).innerHTML += settings_entry;
|
||||||
|
});
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
document.body.innerHTML += settings_HTML;
|
document.body.innerHTML += settings_HTML;
|
||||||
|
|
Loading…
Reference in a new issue