From 67ac30f1bf4f5a3f5506d8802f75eb365b5d4894 Mon Sep 17 00:00:00 2001 From: LitoMore Date: Sun, 28 Jan 2024 23:02:57 +0800 Subject: [PATCH] Remove deprecated `window` usages --- userscripts/epic-games.user.js | 8 ++++---- userscripts/xbox.user.js | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/userscripts/epic-games.user.js b/userscripts/epic-games.user.js index 7226a71..e709bdd 100644 --- a/userscripts/epic-games.user.js +++ b/userscripts/epic-games.user.js @@ -16,7 +16,7 @@ const uesrConfig = { developmentMode: false, // Use development mode, games won't actually claim. }; -const { configure, fireEvent, screen, waitFor } = window.TestingLibraryDom; +const { configure, fireEvent, screen, waitFor } = globalThis.TestingLibraryDom; configure({ asyncUtilTimeout: 1000 * 30 }); @@ -34,7 +34,7 @@ redeemEntrance.addEventListener("mouseenter", () => { }); document.body.appendChild(redeemEntrance); -if (window.location.pathname.includes("/purchase")) { +if (globalThis.location.pathname.includes("/purchase")) { redeemEntrance.style.display = "none"; try { await waitForPlaceOrder(); @@ -55,7 +55,7 @@ function getFreeGames() { el, name: el.querySelector('[data-testid="offer-title-info-title"]').textContent, - url: window.location.origin + el.getAttribute("href"), + url: globalThis.location.origin + el.getAttribute("href"), })); return freeGames; @@ -127,7 +127,7 @@ async function redeem(game) { async function redeemAll() { if (!checkLoginState()) { - window.alert("Requires sign-in for redeeming games."); + globalThis.alert("Requires sign-in for redeeming games."); return; } diff --git a/userscripts/xbox.user.js b/userscripts/xbox.user.js index ebfcdd0..95bd851 100644 --- a/userscripts/xbox.user.js +++ b/userscripts/xbox.user.js @@ -12,7 +12,7 @@ // ==/UserScript== const { configure, fireEvent, screen, waitFor, within } = - window.TestingLibraryDom; + globalThis.TestingLibraryDom; configure({ asyncUtilTimeout: 1000 * 30 }); @@ -34,11 +34,11 @@ redeemEntrance.addEventListener("mouseenter", () => { document.body.appendChild(redeemEntrance); async function processes() { - if (/^\/[a-z]{2}-[a-z]{2}\/$/i.exec(window.location.pathname)) { + if (/^\/[a-z]{2}-[a-z]{2}\/$/i.exec(globalThis.location.pathname)) { localStorage.removeItem("xbox-redeem"); } - if (window.location.pathname.includes("/live/gold")) { + if (globalThis.location.pathname.includes("/live/gold")) { fireEvent.click(document.querySelector('a[href="#gameswithgold"]')); const freeGames = (await screen.findAllByLabelText(/Free with gold/)).map( ( @@ -55,8 +55,8 @@ async function processes() { redeemEntrance.textContent = "DonE"; } - if (window.location.pathname.includes("/games/store/")) { - const storageKey = `xbox-redeem:${window.location.pathname}`; + if (globalThis.location.pathname.includes("/games/store/")) { + const storageKey = `xbox-redeem:${globalThis.location.pathname}`; try { await Promise.any([checkIfOwned(), checkIfAvailable()]); } catch (error) {