Skip to content

Commit

Permalink
Fix giveaway features for game pages (close rafaelgomesxyz#1774)
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelgomesxyz committed Jul 27, 2023
1 parent 2840040 commit 344235d
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
9 changes: 9 additions & 0 deletions src/class/Esgst.js
Original file line number Diff line number Diff line change
Expand Up @@ -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` },
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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/);
Expand Down
6 changes: 5 additions & 1 deletion src/modules/Filters.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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/)
? {
Expand Down Expand Up @@ -2288,6 +2290,7 @@ class Filters extends Module {
'Created',
'Entered',
'Won',
'Games',
'Groups',
'User',
'Gb',
Expand Down Expand Up @@ -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;
Expand Down
5 changes: 4 additions & 1 deletion src/modules/Giveaways.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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 &&
Expand Down
4 changes: 3 additions & 1 deletion src/modules/Giveaways/GiveawayFilters.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
) {
Expand Down Expand Up @@ -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 (
Expand Down
3 changes: 3 additions & 0 deletions src/modules/Giveaways/GiveawaysSorter.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class GiveawaysGiveawaysSorter extends Module {
!popup &&
!this.esgst.giveawaysPath &&
!this.esgst.enteredPath &&
!this.esgst.gamePath &&
!this.esgst.groupPath &&
!this.esgst.userPath
)
Expand All @@ -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) {
Expand Down

0 comments on commit 344235d

Please sign in to comment.