Skip to content

Commit 415274f

Browse files
committed
fix bug for buttons not loading in collection page sometimes
1 parent f3443af commit 415274f

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

ItchioSimpleRemoveFromCollection.user.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ $(document).ready(function () {
2929

3030
let pageUrl = window.location.href
3131
if (IsAddToCollectionPage(pageUrl)) {
32-
// TODO: not working in page with url like example: https://itch.io/g/tobyfox/deltarune/add-to-collection?source=home
3332
if (!GameInCollection()) { return }
3433

3534
let gameCreator = GetUserFromGamePage(pageUrl)
@@ -145,10 +144,18 @@ $(document).ready(function () {
145144
}
146145

147146
function GetUserFromGamePage(url) {
148-
return url.split("/")[2].split(".")[0]
147+
if (url.includes("?source=game")) {
148+
return url.split("/")[2].split(".")[0]
149+
} else {
150+
return url.split("/")[4]
151+
}
149152
}
150153

151154
function GetGameNameFromGamePage(url) {
152-
return url.split("/")[3]
155+
if (url.includes("?source=game")) {
156+
return url.split("/")[3]
157+
} else {
158+
return url.split("/")[5]
159+
}
153160
}
154161
});

0 commit comments

Comments
 (0)