Skip to content

Commit

Permalink
properly account for non-2 ticket cost event boxes
Browse files Browse the repository at this point in the history
  • Loading branch information
menma1234 committed Nov 12, 2022
1 parent ae4437c commit 2e50dab
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "GBF Item Magic",
"version": "1.5.10",
"version": "1.5.11",
"minimum_chrome_version": "40.0",
"manifest_version": 2,
"description": "Provides various tools for saving time in Granblue Fantasy when working with items.",
Expand Down
16 changes: 13 additions & 3 deletions src/content/gacha.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
if(single.getAttribute("disable") === "true") {
var tickets = getNumTickets(doc);

if(tickets > 1) {
if(tickets > 1 && doc.getElementsByClassName("btn-reset").length) {
if(!autoReset) {
alert("The box is empty. Please reset the box and try again.");
} else {
Expand Down Expand Up @@ -149,12 +149,13 @@

var duplicateKey = single.getAttribute("data-duplicate-key");
var count = 1;
var cost = getSinglePullTicketCost(doc);

if(multi !== null) {
count = multi.getAttribute("count");
}

if(max !== null && max < count * 2) {
if(max !== null && max < count * cost) {
count = 1;
}

Expand All @@ -165,7 +166,7 @@

req.onload = function() {
if(max) {
max -= count * 2;
max -= count * cost;
}
contentAction(id);
};
Expand Down Expand Up @@ -281,6 +282,15 @@
return null;
}

function getSinglePullTicketCost(doc) {
var costDiv = doc.querySelector(".prt-medal-obtain:not(.multi) .txt-medal-cost");
if(costDiv) {
return parseInt(doc.querySelector(".prt-medal-obtain:not(.multi) .txt-medal-cost").textContent);
}

return null;
}

function hasResetButton(doc) {
return doc.getElementsByClassName("btn-reset").length > 0;
}
Expand Down

0 comments on commit 2e50dab

Please sign in to comment.