JSON to netscape convert

myndeswx

Client
Регистрация
15.05.2017
Сообщения
399
Благодарностей
88
Баллы
28
Hello, maybe someone has made a snippet to convert JSON cookies for zennoposter to understand? (netscape format)?
Thank you :-)
 

VladZen

Administrator
Команда форума
Регистрация
05.11.2014
Сообщения
22 189
Благодарностей
5 830
Баллы
113
You can use EditThisCookie extension for chrome to import JSON and export Netscape cookies.
 
  • Спасибо
Реакции: myndeswx

myndeswx

Client
Регистрация
15.05.2017
Сообщения
399
Благодарностей
88
Баллы
28
[QUOTE = "VladZen, post: 493049, member: 8322"]
You can use EditThisCookie extension for chrome to import JSON and export Netscape cookies.
[/ QUOTE]
Any guide on the forum how to work with extensions on zenno?
 

Stelsgrower

Client
Регистрация
21.12.2018
Сообщения
134
Благодарностей
62
Баллы
28
[QUOTE = "VladZen, post: 493049, member: 8322"]
You can use EditThisCookie extension for chrome to import JSON and export Netscape cookies.
[/ QUOTE]
Any guide on the forum how to work with extensions on zenno?
Test it. Pulled out and modified from the extension EditThisCookie
JSON to Netscape:
var cookies = JSON.parse(YOUR_COOKIES);
        var url = "facebook.com";
        var string = "";
        var expDate = 0;
        for (var i = 0; i < cookies.length; i++) {
            cookie = cookies[i];
            if(i === 0) expDate = cookie.expirationDate;
            string += cookie.domain + "\t" +
                (!cookie.hostOnly).toString().toUpperCase() + "\t" +
                cookie.path + "\t" +
                cookie.secure.toString().toUpperCase() + "\t" +
                (!!cookie.expirationDate ? convert("("+cookie.expirationDate+")") : convert("("+expDate+")")) + "\t" +
                cookie.name + "\t" +
                cookie.value + "\tTRUE\tFALSE"+((i === cookies.length - 1) ? "" : "\n");
      // console.log(!!cookie.expirationDate);
}

function convert(timestamp) {
  var date = new Date(                          // Convert to date
    parseInt(                                   // Convert to integer
      timestamp.split("(")[1]                   // Take only the part right of the "("
    )*1000
  );
  return [("0" + (date.getMonth()+1)).slice(-2),("0" + date.getDate()).slice(-2),date.getFullYear()].join('/') + " " + date.toLocaleTimeString();
}
Upd: там костыль этот кривой со скобками надо убрать, а я забыл)
 
Последнее редактирование:

Yuriy Zymlex

Moderator
Команда форума
Регистрация
24.10.2016
Сообщения
6 352
Благодарностей
3 279
Баллы
113
  • Спасибо
Реакции: depo и FRAPS

Кто просматривает тему: (Всего: 1, Пользователи: 0, Гости: 1)