Skip to content

Instantly share code, notes, and snippets.

@CodySwannGT
Created January 9, 2017 04:31
Show Gist options
  • Save CodySwannGT/bfdd63939e7b6a72b66296b71420821f to your computer and use it in GitHub Desktop.
Save CodySwannGT/bfdd63939e7b6a72b66296b71420821f to your computer and use it in GitHub Desktop.
/*******************************************************
# * By Gunner Technology contact@gunnertech.com
# *
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version as long as your provide attribution.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Usage: ```node showMeMyDrops.js [your session cookie]```
Prerequisites: I've only tested this on a Mac with an iPhone 7.
That said, as long as you have your session cookie, it should work on platform that has node installed.
The tricky part is getting your session cookie.
The way I did it is outlined here: http://useyourloaf.com/blog/remote-packet-capture-for-ios-devices/
Once you have that setup, you'll have to look through the packets for a section that looks like this:
```
GET /dff/battle/?timestamp=1483926335&battle_id=1050901738 HTTP/1.1
Host: ffrk.denagames.com
Cookie: http_session_sid=xxxxxxxxxxxxxxxxxxxxx
Connection: keep-alive
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 10_1 like Mac OS X) AppleWebKit/602.2.14 (KHTML, like Gecko) Mobile/14B72c
Referer: http://ffrk.denagames.com/dff/?timestamp=1483926300
Accept-Language: en-us
Accept-Encoding: gzip, deflate
```
The key in all that mess is "http_session_sid" - find that and you're golden (don't copy any semicolons)
Once you have that just run this from terminal, command line or whatever.
```
node showMeMyDrops.js [your session cookie]
```
And then go into a battle.
Every few seconds, the script will print what you're going to get.
Couple things to note:
1) If you're not familiar with technical stuff, this might be more hassel than it's worth
2) I won't be able to offer much in the way of support, but I will try to update the Id map. Right now it's just going to show Greater, Major and Crystals - if you know JSON and want to help me out with more, awesome.
3) It doesn't work with MP Raid Dungeons (solo is fine). This is intentional.
# *******************************************************/
var YOUR_SESSION_COOKIE = '<PUT YOUR SESSION COOKIE HERE OR PASS IT AS AN ARGUMENT>';
var CURRENT_PATH = '/dff/event/challenge/90/get_battle_init_data';
var LOOP_FREQUENCY = 8000; // Set to 0 to turn off
var sessionCookie = YOUR_SESSION_COOKIE || (process.argv[2] ? process.argv[2][0] : null);
if(!sessionCookie) {
throw "You must pass your session cookie or set it as a constant";
}
var itemMap = {
"40000004": "Greater Power Orb",
"40000005": "Major Power Orb",
"40000009": "Greater White Orb",
"40000010": "Major White Orb",
"40000014": "Greater Black Orb",
"40000015": "Major Black Orb",
"40000024": "Greater Summon Orb",
"40000025": "Major Summon Orb",
"40000029": "Greater Non Elemental Orb",
"40000030": "Major Non Elemental Orb",
"40000034": "Greater Fire Orb",
"40000035": "Major Fire Orb",
"40000039": "Greater Ice Orb",
"40000040": "Major Ice Orb",
"40000044": "Greater Lightning Orb",
"40000045": "Major Lightning Orb",
"40000049": "Greater Earth Orb",
"40000050": "Major Earth Orb",
"40000054": "Greater Wind Orb",
"40000055": "Major Wind Orb",
"40000059": "Greater Holy Orb",
"40000060": "Major Holy Orb",
"40000064": "Greater Dark Orb",
"40000065": "Major Dark Orb",
"40000066": "Power Crystal",
"40000067": "White Crystal",
"40000068": "Black Crystal",
"40000070": "Summon Crystal",
"40000071": "Non Elemental Crystal",
"40000072": "Fire Crystal",
"40000073": "Ice Crystal",
"40000074": "Lightning Crystal",
"40000075": "Earth Crystal",
"40000076": "Wind Crystal",
"40000077": "Holy Crystal",
"40000078": "Dark Crystal",
}
var http = require('http');
var options = {
host: 'ffrk.denagames.com',
port: 80,
path: CURRENT_PATH,
headers: {'Cookie': 'http_session_sid='+sessionCookie}
};
function showMeMyDrops() {
var data = "";
var req = http.get(options, function(resp){
resp.on('data', function(chunk) {
data += chunk;
});
resp.on("end", function(){
var json = JSON.parse(data);
var drops = [];
if(!json.success) {
console.log("You're probably not in battle. If you are in battle, you probably need to reset your session cookie");
return;
}
console.log("You're going to get...")
json.battle.rounds.forEach(function(round) {
round.drop_item_list.forEach(function(drop) {
if (itemMap[drop.item_id]) {
if(parseInt(drop.num) > 1) {
drops.push(drop.num + ' ' + itemMap[drop.item_id] + 's');
} else {
drops.push(itemMap[drop.item_id]);
}
} else {
drops.push(drop);
}
});
round.enemy.forEach(function(enemy) {
enemy.children.forEach(function(child) {
child.drop_item_list.forEach(function(drop) {
if (itemMap[drop.item_id]) {
if(parseInt(drop.num) > 1) {
drops.push(drop.num + ' ' + itemMap[drop.item_id] + 's');
} else {
drops.push(itemMap[drop.item_id]);
}
} else {
drops.push(drop);
}
});
});
});
});
if(drops.length) {
drops.forEach(function(drop) { console.log(drop); });
} else {
console.log("...nothing.")
}
});
}).on("error", function(e){
console.log("Got error: " + e.message);
});
req.end();
}
showMeMyDrops();
if(LOOP_FREQUENCY) {
setInterval(function(){ showMeMyDrops() }, LOOP_FREQUENCY);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment