Advertisement
stuppid_bot

VK PM

May 23rd, 2014
335
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @match http://vk.com/*
  3. // @match https://vk.com/*
  4. // ==/UserScript==
  5.  
  6. // вписываем id группы через которую будем постить
  7. GROUP_ID = 71855479;
  8.  
  9. function initPM() {
  10.     localStorage['pm_group_id'] = arguments[0];
  11.     var xhr = new XMLHttpRequest;
  12.     xhr.open('GET', '/club' + localStorage['pm_group_id']);
  13.     xhr.onload = function () {
  14.         var m = xhr.responseText.match(/"post_hash":"([^"]+)/);
  15.         localStorage['pm_post_hash'] = m[1];
  16.     }
  17.     xhr.send();
  18. }
  19.  
  20. // Message=1&act=post&al=1&facebook_export=&fixed=&friends_only=&from=&hash=f8078a2b50a072150b&official=&signed=&status_export=&to_id=-71855479&type=all
  21. /*
  22.  
  23. ajax.post('/al_wall.php', {
  24.     al: 1,
  25.     act: 'post',
  26.     type: 'all',
  27.     hash: localStorage['pm_post_hash'],
  28.     to_id: -localStorage['pm_group_id'],
  29.     Message: 'секс'
  30. }, {
  31.     onDone: function (xhr, data) {
  32.         var m = data.match(/<div id="post([^"]+)/);
  33.         console.log('wall' + m[1]);
  34.     }
  35. });
  36.  
  37. */
  38.  
  39. function exec(func, args) {
  40.     scr = document.createElement('script');
  41.     scr.innerHTML = '(' + func + ')(' + (args || '') + ')';
  42.     document.head.appendChild(scr);
  43. }
  44.  
  45. // во фреймах не загружаем
  46. if (top == this) {
  47.     var loc;
  48.     setInterval(function () {
  49.         var cur = location.pathname + location.search;
  50.  
  51.         if (loc != cur) {
  52.             loc = cur;
  53.             console.log('Адрес изменился: ' + loc);
  54.            
  55.             if (location.pathname == '/im' && location.search.indexOf('sel=') > -1) {
  56.                 console.log('update form');
  57.             }
  58.         }
  59.     }, 10);
  60.     exec(initPM, GROUP_ID);
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement