Skip to content

Commit

Permalink
fixes for dread barrage gacha
Browse files Browse the repository at this point in the history
  • Loading branch information
menma1234 committed Jul 1, 2021
1 parent 329eb76 commit 161caf9
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 7 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.6",
"version": "1.5.7",
"minimum_chrome_version": "40.0",
"manifest_version": 2,
"description": "Provides various tools for saving time in Granblue Fantasy when working with items.",
Expand Down
34 changes: 28 additions & 6 deletions src/content/gacha.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
}

function doBulkPull(id) {
var url = buildUrl("/" + eventName + "/rest/gacha/bulk_play", uid);
var url = buildUrl(mungeRestUrl("/" + eventName + "/rest/gacha/bulk_play"), uid);

var req = new XMLHttpRequest();
req.open("POST", url);
Expand All @@ -80,6 +80,28 @@
req.setRequestHeader("Content-Type", "application/json");
req.send(JSON.stringify({special_token: null, gacha_id: id}));
}

function mungeRestUrl(url) {
if (url.indexOf("rest") > -1 && url.indexOf("teamforce") > -1) {
var parts = url.split("/");
var restIndex, nameIndex;

for (var i = 0; i < parts.length; i++) {
if (parts[i] === "rest") {
restIndex = i;
} else if (parts[i].indexOf("teamforce") > -1) {
nameIndex = i;
}
}

parts[restIndex] = parts[nameIndex];
parts[nameIndex] = "rest";

url = parts.join("/");
}

return url;
}

function gacha(doc) {
var gachaButtons = doc.getElementsByClassName("btn-medal");
Expand Down Expand Up @@ -131,7 +153,7 @@
count = 1;
}

var url = buildUrl("/" + eventName + "/rest/gacha/play", uid);
var url = buildUrl(mungeRestUrl("/" + eventName + "/rest/gacha/play"), uid);

var req = new XMLHttpRequest();
req.open("POST", url);
Expand Down Expand Up @@ -165,7 +187,7 @@

function result1(eventId, seq) {
seq++;
var url = buildUrl("/" + eventName + "/rest/gacha/result/" + eventId, uid, seq);
var url = buildUrl(mungeRestUrl("/" + eventName + "/rest/gacha/result/" + eventId), uid, seq);

var req = new XMLHttpRequest();
req.open("GET", url);
Expand Down Expand Up @@ -198,7 +220,7 @@

function result2(eventId, seq, doc) {
seq++;
var url = buildUrl("/" + eventName + "/rest/gacha/result/" + eventId, uid, seq);
var url = buildUrl(mungeRestUrl("/" + eventName + "/rest/gacha/result/" + eventId), uid, seq);

var req = new XMLHttpRequest();
req.open("GET", url);
Expand Down Expand Up @@ -255,7 +277,7 @@
var boxId = parseInt(resetButton.getAttribute("data-box-id"));
var duplicateKey = resetButton.getAttribute("data-duplicate-key");

var url = buildUrl("/" + eventName + "/rest/gacha/reset_box", uid);
var url = buildUrl(mungeRestUrl("/" + eventName + "/rest/gacha/reset_box"), uid);

var req = new XMLHttpRequest();
req.open("POST", url);
Expand All @@ -270,7 +292,7 @@

function getGachaIndex(callback) {
var url;
if(eventName.startsWith("teamraid")) {
if(eventName.startsWith("teamraid") || eventName.indexOf("teamforce") > -1) {
url = buildUrl("/" + eventName + "/gacha/content/index", uid);
} else {
if(isEventEnded) {
Expand Down

0 comments on commit 161caf9

Please sign in to comment.