Update builded.user.js
Some checks are pending
Check syntax / check (push) Waiting to run

This commit is contained in:
Nova Cat 2025-01-03 22:54:39 -08:00
parent 3814ebdcff
commit 41c0ea464e

View file

@ -14,7 +14,26 @@
// @require https://github.com/pie6k/jquery.initialize/raw/refs/heads/master/jquery.initialize.min.js
// @run-at document-end
// ==/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 = `
<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.");
$.initialize('.DesktopOptionsControl-persistent-menu', function() {
console.info("Settings opened!")
$(this).innerHTML += settings_entry;
waitForElm('.PersistentActionMenuSection-container').then((elm) => {
console.log('Injecting Builded settings...');
$(this).innerHTML += settings_entry;
});
});
} else {
document.body.innerHTML += settings_HTML;