Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/js/Content/Features/LegacyPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import ITAD from "@Content/Modules/ITAD";
export default class LegacyPage extends Page {

override check(): boolean {
return !!document.getElementById("global_header");
return !!document.querySelector("#global_header, .responsive_page_frame.no_header");
}

protected override async getAppConfig(factory: AppConfigFactory): Promise<AppConfig> {
Expand Down
22 changes: 21 additions & 1 deletion src/js/Content/Features/Page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,32 @@ export default abstract class Page {
protected abstract getLanguage(factory: LanguageFactory): Promise<Language|null>;
protected abstract getUser(factory: UserFactory): Promise<UserInterface>;

private async waitForCheck(timeout = 10000): Promise<boolean> {
if (this.check()) { return true; }

return new Promise(resolve => {
const observer = new MutationObserver(() => {
if (!this.check()) { return; }

window.clearTimeout(timeoutId);
observer.disconnect();
resolve(true);
});
const timeoutId = window.setTimeout(() => {
observer.disconnect();
resolve(false);
}, timeout);

observer.observe(document.documentElement, {childList: true, subtree: true});
});
}

async run(): Promise<void> {
if (document.querySelector("#as-menu")) {
// already loaded
return;
}
if (!this.check()) { return; }
if (!await this.waitForCheck()) { return; }

let language: Language|null;
let user: UserInterface;
Expand Down
15 changes: 14 additions & 1 deletion src/js/Content/Features/Store/App/PApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,17 @@
import CApp from "@Content/Features/Store/App/CApp";
import StorePage from "@Content/Features/StorePage";

(new StorePage(CApp)).run();
const page = new StorePage(CApp);
const selector = ".page_content_ctn > .page_content, #error_box";

if (document.querySelector(selector)) {
page.run();
} else {
const observer = new MutationObserver(() => {
if (!document.querySelector(selector)) { return; }

observer.disconnect();
page.run();
});
observer.observe(document.documentElement, {childList: true, subtree: true});
}
9 changes: 7 additions & 2 deletions src/js/Content/Modules/AugmentedSteam.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ export default class AugmentedSteam {
const target = document.querySelector(this.react
? "header nav + div"
: "#global_action_menu"
)!;
);
if (!target) {
console.warn("Augmented Steam menu is unavailable on this page");
return;
}

(new AugmentedSteamMenu({
target,
Expand Down Expand Up @@ -116,7 +120,8 @@ export default class AugmentedSteam {
target = document.querySelector("header ~ section");
anchor = target?.firstElementChild ?? null;
} else {
const header = document.querySelector("#global_header")!
const header = document.querySelector("#global_header");
if (!header) { return; }
target = header.parentElement!;
anchor = header.nextElementSibling!;
}
Expand Down