From 344235dae2a92a53d991333211dd2bf21928a7d2 Mon Sep 17 00:00:00 2001 From: Rafael Gomes Date: Wed, 26 Jul 2023 22:54:02 -0300 Subject: [PATCH] Fix giveaway features for game pages (close #1774) --- package.json | 2 +- src/class/Esgst.js | 9 +++++++++ src/modules/Filters.jsx | 6 +++++- src/modules/Giveaways.jsx | 5 ++++- src/modules/Giveaways/GiveawayFilters.jsx | 4 +++- src/modules/Giveaways/GiveawaysSorter.jsx | 3 +++ 6 files changed, 25 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index b8a6cc22..939c03dd 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "esgst", "version": "8.9.4", - "betaVersion": "8.10.0-beta.2", + "betaVersion": "8.10.0-beta.3", "title": "Enhanced SteamGifts & SteamTrades (ESGST)", "description": "A script that adds some cool features to SteamGifts and SteamTrades.", "author": "rafaelgomesxyz", diff --git a/src/class/Esgst.js b/src/class/Esgst.js index e414a471..5fe0f886 100644 --- a/src/class/Esgst.js +++ b/src/class/Esgst.js @@ -102,6 +102,13 @@ class Esgst { name: 'Giveaway - Region Restrictions', pattern: `^/giveaway/.{5}/[A-Za-z0-9-]+/region-restrictions`, }, + { name: 'Game', pattern: '^/game/' }, + { name: 'Game - Giveaways', pattern: `^/game/.+?/[^/]+($|/search)` }, + { name: 'Game - Coming Soon', pattern: `^/game/.+?/[^/]+/coming-soon` }, + { name: 'Game - Open', pattern: `^/game/.+?/[^/]+/open` }, + { name: 'Game - Closed', pattern: `^/game/.+?/[^/]+/closed` }, + { name: 'Game - Deleted', pattern: `^/game/.+?/[^/]+/deleted` }, + { name: 'Game - Stats', pattern: `^/game/.+?/[^/]+/stats` }, { name: 'Group', pattern: '^/group/' }, { name: 'Group - Giveaways', pattern: `^/group/.+?/[^/]+($|/search)` }, { name: 'Group - Users', pattern: `^/group/.+?/[^/]+/users` }, @@ -293,6 +300,7 @@ class Esgst { this.elgbCache = {}; this.originalHash = window.location.hash; this.userPath = false; + this.gamePath = false; this.groupPath = false; this.regionsPath = false; this.groupWishlistPath = false; @@ -540,6 +548,7 @@ class Esgst { this.userPath = window.location.pathname.match(/^\/user\//); this.userWonPath = this.userPath && window.location.pathname.match(/\/giveaways\/won/); + this.gamePath = window.location.pathname.match(/^\/game\//); this.groupPath = window.location.pathname.match(/^\/group\//); this.regionsPath = window.location.pathname.match(/^\/regions\//); this.groupWishlistPath = window.location.pathname.match(/^\/group\/(.*?)\/wishlist/); diff --git a/src/modules/Filters.jsx b/src/modules/Filters.jsx index 633d0cee..b8bc518c 100644 --- a/src/modules/Filters.jsx +++ b/src/modules/Filters.jsx @@ -83,7 +83,9 @@ class Filters extends Module { rules: null, type: popup || - (this.esgst.groupPath + (this.esgst.gamePath + ? 'Games' + : this.esgst.groupPath ? 'Groups' : window.location.search.match(/type/) ? { @@ -2288,6 +2290,7 @@ class Filters extends Module { 'Created', 'Entered', 'Won', + 'Games', 'Groups', 'User', 'Gb', @@ -2604,6 +2607,7 @@ class Filters extends Module { this.esgst.enteredPath || this.esgst.wonPath || this.esgst.userPath || + this.esgst.gamePath || this.esgst.groupPath) ) { this.esgst.stopEs = true; diff --git a/src/modules/Giveaways.jsx b/src/modules/Giveaways.jsx index 193e4832..ef04a72d 100644 --- a/src/modules/Giveaways.jsx +++ b/src/modules/Giveaways.jsx @@ -84,6 +84,8 @@ class Giveaways extends Module { 'X.featured__outer-wrap--giveaway', `.table:not(.table--summary) X.table__row-outer-wrap`, ]); + } else if (this.esgst.gamePath) { + query = Shared.common.getSelectors(endless, ['X.giveaway__row-outer-wrap']); } else { query = Shared.common.getSelectors(endless, [ 'X.giveaway__row-outer-wrap', @@ -194,6 +196,7 @@ class Giveaways extends Module { ); const archivePath = common.testPath('Archive', 'sg', mainUrl || window.location.pathname); const giveawaysPath = common.testPath('Giveaways', 'sg', mainUrl || window.location.pathname); + const gamePath = common.testPath('Game', 'sg', mainUrl || window.location.pathname); const groupPath = common.testPath('Group', 'sg', mainUrl || window.location.pathname); const userPath = common.testPath( 'User - Giveaways - Sent', @@ -393,7 +396,7 @@ class Giveaways extends Module { if (Settings.get('gf') && Settings.get('gf_s') && main) { let savedGiveaway = this.esgst.giveaways[giveaway.code]; if ( - (giveawaysPath || groupPath) && + (giveawaysPath || gamePath || groupPath) && savedGiveaway && savedGiveaway.hidden && savedGiveaway.code && diff --git a/src/modules/Giveaways/GiveawayFilters.jsx b/src/modules/Giveaways/GiveawayFilters.jsx index b1b6999c..ea6eb697 100644 --- a/src/modules/Giveaways/GiveawayFilters.jsx +++ b/src/modules/Giveaways/GiveawayFilters.jsx @@ -916,6 +916,7 @@ class GiveawaysGiveawayFilters extends Filters { this.esgst.createdPath || this.esgst.enteredPath || this.esgst.wonPath || + this.esgst.gamePath || this.esgst.groupPath || this.esgst.userPath) ) { @@ -1009,7 +1010,8 @@ class GiveawaysGiveawayFilters extends Filters { } } if ( - (source !== 'gc' && (this.esgst.giveawaysPath || this.esgst.groupPath)) || + (source !== 'gc' && + (this.esgst.giveawaysPath || this.esgst.gamePath || this.esgst.groupPath)) || this.esgst.giveawayPath ) { if ( diff --git a/src/modules/Giveaways/GiveawaysSorter.jsx b/src/modules/Giveaways/GiveawaysSorter.jsx index 9a5583bf..80f2e65d 100644 --- a/src/modules/Giveaways/GiveawaysSorter.jsx +++ b/src/modules/Giveaways/GiveawaysSorter.jsx @@ -47,6 +47,7 @@ class GiveawaysGiveawaysSorter extends Module { !popup && !this.esgst.giveawaysPath && !this.esgst.enteredPath && + !this.esgst.gamePath && !this.esgst.groupPath && !this.esgst.userPath ) @@ -60,6 +61,8 @@ class GiveawaysGiveawaysSorter extends Module { type = 'Entered'; } else if (this.esgst.userPath) { type = 'User'; + } else if (this.esgst.gamePath) { + type = 'Games'; } else if (this.esgst.groupPath) { type = 'Groups'; } else if (popup) {