Skip to content

Commit

Permalink
Remove deprecated window usages
Browse files Browse the repository at this point in the history
  • Loading branch information
LitoMore committed Jan 28, 2024
1 parent e40c571 commit 67ac30f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions userscripts/epic-games.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 });

Expand All @@ -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();
Expand All @@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down
10 changes: 5 additions & 5 deletions userscripts/xbox.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// ==/UserScript==

const { configure, fireEvent, screen, waitFor, within } =
window.TestingLibraryDom;
globalThis.TestingLibraryDom;

configure({ asyncUtilTimeout: 1000 * 30 });

Expand All @@ -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(
(
Expand All @@ -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) {
Expand Down

0 comments on commit 67ac30f

Please sign in to comment.