It seems to work as intended!
GLOBAL VARIABLES (On top of script):
If you don't have C:\Rules folder create it.
Code:
var Quest = true;
var MarketUpdaterPath = "C:\\Rules\\";
Inside OnBeforeRequest:
Code:
if (Quest && oSession.uriContains("api/v1/archives/stories/update/quest-progress-v3")){
try{
if (MarketUpdaterPath[-1] != "\\") MarketUpdaterPath += "\\";
var questPath = MarketUpdaterPath + "Quest.json";
if (!System.IO.File.Exists(questPath)) return;
var questString = System.IO.File.ReadAllText(questPath);
var questJson = Fiddler.WebFormats.JSON.JsonDecode(questString);
oSession.utilDecodeRequest();
var jsonString = oSession.GetRequestBodyAsString();
var oJson = Fiddler.WebFormats.JSON.JsonDecode(jsonString);
oJson.JSONObject["questEvents"] = questJson.JSONObject["questEvents"];
oJson.JSONObject["role"] = questJson.JSONObject["role"];
var oString = Fiddler.WebFormats.JSON.JsonEncode(oJson.JSONObject);
oSession.utilSetRequestBody(oString);
}
catch(e){
FiddlerObject.log(e);
}
}
Inside OnBeforeResponse (Delete old Quest script than paste this instead):
Code:
if (Quest && oSession.uriContains("api/v1/archives/stories/update/active-node-v3")){
try{
//DECODING AND CONVERTING REQUEST AND RESPONSE
oSession.utilDecodeRequest();
oSession.utilDecodeResponse();
var jsonRequest = oSession.GetRequestBodyAsString();
var oJsonRequest = Fiddler.WebFormats.JSON.JsonDecode(jsonRequest);
var jsonResponse = oSession.GetResponseBodyAsString();
var oJsonResponse = Fiddler.WebFormats.JSON.JsonDecode(jsonResponse);
//GETTING VARIABLES FROM SELECTED CHALLENGE
if(oJsonResponse.JSONObject["activeNodesFull"].Count == 0) return;
var role = oJsonRequest.JSONObject["role"];
if(role == "both") role = "survivor";
var neededProgression = oJsonResponse.JSONObject["activeNodesFull"][0]["objectives"][0]["neededProgression"];
var questEvents = oJsonResponse.JSONObject["activeNodesFull"][0]["objectives"][0]["questEvent"];
var matchId = System.Guid.NewGuid().ToString();
var requestBody = '{"matchId":"'+matchId+'","questEvents":[';
for(var i=0;i<questEvents.Count;i++){
var repetition = questEvents[i]["repetition"];
repetition *= neededProgression;
var questEventId = questEvents[i]["questEventId"];
var parameters = questEvents[i]["parameters"];
if(parameters != undefined) requestBody += '{"parameters":"'+parameters+'","questEventId":"'+questEventId+'","repetition":'+repetition+'}';
else requestBody += '{"questEventId":"'+questEventId+'","repetition":'+repetition+'}';
if(questEvents.Count > 1 && i != questEvents.Count - 1) requestBody += ",";
}
requestBody += '],"role":"'+role+'"}';
//GENERATING QUEST FILE
System.IO.File.WriteAllText(MarketUpdaterPath+"Quest.json", requestBody);
}
catch(e){FiddlerObject.log("Error unlocking challenge");}
}
USAGE
Select 1 challenge at time for 1 role only then play with that role, challenge automatically completes also if you don't do that.