-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdecodeCookie.js
72 lines (61 loc) · 2.04 KB
/
decodeCookie.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
const fs = require("fs");
const readline = require("readline");
const cookiesString = fs.readFileSync("cookies.txt", {
encoding: "utf8",
flag: "r",
});
const { getUserNameFromTxt, getCookieString } = require("./utils");
// let lineReader = require('line-reader');
//
// lineReader.eachLine('cookies.txt', function(line, last) {
// console.log(line);
// // do whatever you want with line...
// if(last){
// // or check if it's the last one
// console.log("last line!")
// }
// });
const decodeCookies = () => {
const file = fs.readFileSync("./order.txt");
let eachLine = file.toString().split("\n");
let eachLineNew = [];
eachLine.map((ele, index) => {
if (ele !== "") {
eachLineNew.push(ele);
}
});
eachLineNew.map((ele, index) => {
// console.log(getUserNameFromTxt(ele))
let userName = getUserNameFromTxt(ele);
let cookiesString = getCookieString(ele);
let b64string = cookiesString;
let buf = Buffer.from(b64string, "base64"); // Ta-da
let text = buf.toString();
const newText = text.replace(/'/g, '"');
const newText2 = newText.replace(/True/g, "true");
const newText3 = newText2.replace(/False/g, "false");
const newText4 = newText3.replace(/""/g, '"');
let parsedCookies = JSON.parse(newText4);
console.log(parsedCookies);
fs.writeFileSync(
`./cookies/${userName}.json`,
JSON.stringify(parsedCookies)
);
});
};
// console.log(cookiesString)
// const parsedCookies = JSON.parse(cookiesString);
// console.log(parsedCookies);
//*********************************************
// let b64string = cookiesString;
// let buf = Buffer.from(b64string, 'base64'); // Ta-da
// let text = buf.toString();
// const newText = text.replace(/'/g,'"');
// const newText2 = newText.replace(/True/g,"true");
// const newText3 = newText2.replace(/False/g,"false")
// const newText4 = newText3.replace(/""/g,'"')
// let parsedCookies = JSON.parse(newText4);
//
//
// console.log(parsedCookies)
// fs.writeFileSync("./cookies.json",JSON.stringify(parsedCookies))