Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @match http://vk.com/*
- // @match https://vk.com/*
- // @description Постим сообщения в личку через группу, чтобы их потом можно было удалить
- // ==/UserScript==
- // УСТАНОВКА
- //
- // Сохраните текст скрипта в виде файла с именем %название%.user.js. Потом откройте в Хроме chrome://extensions, выберите расширения и перетащите туда файл. Вот и вся установка.
- // вписываем id группы через которую будем постить
- GROUP_ID = 71985986;
- function exec(func, args) {
- args = args || '';
- var scr = document.createElement('script');
- scr.innerHTML = '(' + func + ')(' + args + ')';
- document.head.appendChild(scr);
- }
- if (this == top) {
- var loc;
- setInterval(function () {
- var cur = location.pathname + location.search;
- if (loc != cur) {
- loc = cur;
- console.log('Адрес изменился: ' + loc);
- if (location.pathname == '/im' && location.search.indexOf('sel=') > -1 && !document.getElementById('pm_container')) {
- exec(function (group_id) {
- function getContent(url, cb) {
- var xhr = new XMLHttpRequest;
- xhr.open('GET', url);
- xhr.onload = function () {
- cb(xhr.responseText)
- }
- xhr.send();
- }
- window.onCtrlEnter = function (evt) {
- if (evt.ctrlKey && (evt.keyCode == 0xA || event.keyCode == 0xD)) {
- ge('pm_send').onclick();
- }
- }
- window.pm_send = function (post_hash) {
- var txt = val('pm_txt').trim();
- if (txt == '') return;
- val('pm_txt', '');
- ajax.post('/al_wall.php', {
- al: 1,
- official: 1,
- act: 'post',
- type: 'all',
- hash: post_hash,
- to_id: -group_id,
- Message: txt
- }, {
- onDone: function (data) {
- // console.log(arguments);
- var matches = data.match(/<div id="post([^"]+)/);
- var entry = 'wall' + matches[1];
- console.log(entry);
- getContent('/like.php?act=publish_box&al=1&object=' + entry, function (data) {
- var matches = data.match(/imHash: '([^']+)/);
- ajax.post('/al_mail.php', {
- // Message: '',
- act: 'a_send',
- ajax: 1,
- al: 1,
- chas: matches[1],
- from: 'box',
- media: entry,
- // title: '',
- to_ids: cur.peer
- });
- });
- }
- });
- }
- getContent('/club' + group_id, function (data) {
- var matches = data.match(/"post_hash":"([^"]+)/);
- var A = document.getElementById('im_resizer_wrap');
- var B = document.createElement('div');
- B.id = 'pm_container';
- B.innerHTML = '<textarea id="pm_txt" style="width: 300px" onkeypress="onCtrlEnter(event)"></textarea>' +
- '<button id="pm_send" onclick="pm_send(\'' + matches[1] + '\')">Репостим</button>'
- A.parentNode.insertBefore(B, A);
- });
- }, GROUP_ID);
- }
- }
- }, 10);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement