JSON to netscape convert

  • Автор темы Автор темы myndeswx
  • Дата начала Дата начала

myndeswx

Client
Регистрация
15.05.2017
Сообщения
437
Реакции
104
Баллы
43
Hello, maybe someone has made a snippet to convert JSON cookies for zennoposter to understand? (netscape format)?
Thank you :)
 
You can use EditThisCookie extension for chrome to import JSON and export Netscape cookies.
 
  • Спасибо
Реакции: myndeswx
[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?
 
[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: там костыль этот кривой со скобками надо убрать, а я забыл)
 
Последнее редактирование:

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