Last active
May 6, 2018 13:41
-
-
Save vikegart/637ffcfa017b2567f9c89a399259d120 to your computer and use it in GitHub Desktop.
Script for VK vkontakte - who write first in vk messages. For use - open dialog with your friend and open console and put the code to them. Просто открой диалог с кем-то и открой консоль = CTRL + SHIFT + J и вставь это и нажми ENTER
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var delay_between = 60 * 60 * 2 //2 hours, but 12 looks more truth | |
var M = []; | |
var peer = location.href.substr(location.href.indexOf('sel=') + 4); | |
var my_id = vk.id; | |
var im_table = document.getElementsByClassName('im-page--chat-body')[0]; | |
im_table.innerHTML = ''; | |
function load_history(part) { | |
if (part === 0) var offset = 0; | |
if (part === 1) var offset = 30; | |
if (part > 1) var offset = 30 + 100 * (part - 1); | |
ajax.post('al_im.php', { | |
act: 'a_history', | |
peer: peer, // id собеседника | |
offset: offset, | |
al: 1, | |
rev: 0, | |
whole: 0 | |
}, { | |
onDone: function (html, msgs, all_shown, cnts, data) { | |
im_table.innerHTML = html; | |
var im_rows = im_table.getElementsByClassName('im-mess-stack _im_mess_stack'); | |
var row_pack = []; | |
var cnt_rows = 0; | |
each(im_rows, function () { | |
var data_peer = this.getAttribute('data-peer'); | |
if (!data_peer) return; | |
if (data_peer.indexOf(peer) >= 0) { | |
var msg_target = 'in'; | |
} | |
else if (data_peer.indexOf(my_id) >= 0) { | |
var msg_target = 'out'; | |
} | |
if (!msg_target) return; | |
var msg_ts = this.getAttribute('data-ts'); | |
var grabDataEl = this.querySelectorAll('li[data-ts]')[0]; | |
row_pack.push({ | |
target: msg_target, | |
date: grabDataEl.dataset.ts | 0, | |
}); | |
cnt_rows++; | |
}); | |
M = row_pack.concat(M); | |
console.log('Обработано сообщений: ' + M.length); | |
if (!all_shown) load_history(part + 1); | |
else { | |
console.log('finish.'); | |
var lasttime = 0, cnt_in = 0, cnt_out = 0, first_in = 0, first_out = 0; | |
each(M, function () { | |
if (!lasttime || this.date > lasttime + (delay_between)) { | |
if (this.target === 'in') first_in++; | |
else first_out++; | |
} | |
if (this.target === 'in') cnt_in++; | |
else cnt_out++; | |
lasttime = this.date; | |
}); | |
console.log("Всего сообщений: " + M.length + | |
",\nОтправлено: " + cnt_out + | |
",\nПолучено: " + cnt_in + | |
",\nПервым написал я: " + first_out + | |
",\nПервым написали мне: " + first_in); | |
} | |
}, | |
onFail: function () { | |
console.log('ERROR', arguments); | |
} | |
}); | |
return 'скрипт запущен!' | |
} | |
load_history(0); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment