jadefin/mods/FixStuck.js

45 lines
1.1 KiB
JavaScript
Raw Permalink Normal View History

2024-03-01 21:01:22 +01:00
//@ts-check
import JadefinIntegrity from '../JadefinIntegrity.js';
import JadefinMod from "../JadefinMod.js";
export default JadefinIntegrity("FixStuck", import.meta.url, () => new (class FixStuck extends JadefinMod {
constructor() {
super();
}
async init(name, url) {
await super.init(name, url);
2024-05-13 20:48:11 +02:00
if (true) {
// 10.9 seems to have fixed any stuck scenarios.
return;
}
2024-03-01 21:01:22 +01:00
const time =
window.location.hash.startsWith("#!/dialog?") ? 500 :
2500;
setTimeout(() => {
if (this.isStuck) {
this.log.w("Checked, stuck - reloading");
window.location.hash = "";
window.location.reload();
} else {
this.log.i("Checked, not stuck");
}
}, time);
this.log.i("Ready");
}
get isStuck() {
return (
(document.querySelector(".mainAnimatedPages.skinBody")?.childElementCount ?? 0) == 0 &&
!document.querySelector(".mainDrawer > .mainDrawer-scrollContainer > .userMenuOptions")
);
}
})());