NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript==
// @name Exelab mail dumper
// @namespace https://exelab.ru/
// @version 0.1
// @author vovanre
// @match https://exelab.ru/f/*
// @match http://e4unrusy7se5evw5.onion/f/*
// @require https://code.jquery.com/jquery-3.1.1.min.js
// @require https://js.zapjs.com/js/download.js
// @grant unsafeWindow
// ==/UserScript==
$(document).ready(function() {
'use strict';
if (unsafeWindow.confirmDelete == undefined) {
return;
}
var doneMessages = -1;
var totalMessages = -1;
var messages = [];
$('[name=checkedMsgAction]').append('<option value="archivemessage">Архивировать</option>');
var hook = unsafeWindow.confirmDelete;
unsafeWindow.confirmDelete = function() {
var what = document.forms['checkFrm'].elements['checkedMsgAction'].value;
if (what == "archivemessage") {
var data = $(document.forms['checkFrm']).serializeArray();
if (doneMessages == -1 && totalMessages == -1) {
try {
dumpMessages(data.filter(function(x) {
return x.name == "msgid[]";
}));
} catch (err) {
console.log(err);
reset();
alert("Всё сломалось! Смотри консоль.");
}
} else {
alert("Работа ещё не закончена!");
}
} else {
hook();
}
};
function save() {
var output = JSON.stringify(messages, null, 2);
download(output, "messages.json", "application/json");
}
function reset() {
doneMessages = -1;
totalMessages = -1;
messages = [];
}
function updateStatus() {
doneMessages++;
$('#dumpStatus').html(" " + doneMessages + "/" + totalMessages);
if (doneMessages == totalMessages) {
$('#dumpStatus').remove();
save();
reset();
}
}
function dumpMessages(ids) {
$("body > table > tbody > tr:nth-child(7) > td > div:nth-child(4) > form > table > tbody > tr:nth-child(52) > td").append('<b id="dumpStatus"></b>');
totalMessages = ids.length;
updateStatus();
ids.forEach(function(item) {
dumpMessage(item);
});
}
function dumpMessage(oid) {
var id = oid.value;
$.get("index.php?action=pmail&step=viewmsg_inbox&page=0&msg_id=" + id, function(data) {
// ДА ДА ДА, на странице сообщения нет темы -_-
var title = $('[href*="&msg_id=' + id + ']"').html();
var html = $($.parseHTML(data));
var from = html.find(".username").html();
var rawDate = html.find(".tbCel2 > .caption1 > .txtSm:nth-child(1)").html();
rawDate = rawDate.substring(rawDate.indexOf("Отправлено: "), rawDate.indexOf("<br>"));
var date = rawDate.substring("Отправлено: ".length);
html.find(".txtSm").remove();
var text = html.find(".tbCel2 > .caption1:nth-child(2)").html().replace(/<br[^>]*>/g, "\n").trim();
messages.push({
id: id,
title: title,
from: from,
date: date,
text: text
});
updateStatus();
});
}
});