Advertisement
Guest User

Untitled

a guest
Oct 1st, 2014
328
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name        RandomMountainCommenter
  3. // @namespace   odnoklassniki
  4. // @description tvoi mama ibalj
  5. // @include     http://www.odnoklassniki.ru/online
  6. // @include     http://odnoklassniki.ru/online
  7. // @version     1.2.3
  8. // @grant       none
  9. // ==/UserScript==
  10.  
  11. var initialWaitTime = 5000,
  12.     reloadWaitTime = 2000,
  13.     popupWaitTime = 1000,
  14.     photoLoadWaitTime = 2500,
  15.     closeWaitTime = 1000,
  16.     fetchWaitTime = 3000,
  17.    
  18.     minAge = "14",    // >= 14
  19.     maxAge = "29",    // <= 99
  20.    
  21.     cityList = [ "Грозный", "Урус-Мартан", "Гудермес", "Хасавюрт", "Дербент", "Махачкала" ],
  22.     kavkazWordList = ["МАМУ", "ТВАЮ", "КАУКАЗЦЕВ", "ТИ", "В ЖОПУ", "ШЛЮХИ", "И", "А", "ВЫИБУ", "ЕБАЛ", "ТИБЯ", "НАЙДУ", "РОД", "СУКА", "БЛЯ", "СУКИН СЫН",
  23.                         "ЖИ ЕСТЬ", "БАРАН", "СЕСТРУ", "СЕМЬЮ", "ЕБАЛ" ],
  24.     kavkazPhraseEnd = '!!!!!!',
  25.     prevWord = -1;
  26.  
  27. document.getElementsByClass = function(tagName, className) {
  28.   var itemsfound = new Array,
  29.       elems = document.getElementsByTagName(tagName),
  30.       i;
  31.   for(i = 0; i < elems.length; ++i) {
  32.     if(elems[i].className === className) {
  33.       itemsfound.push(elems[i]);
  34.     }
  35.   }
  36.   return itemsfound;
  37. }
  38.  
  39. function getRandomWordIndex() {
  40.     return Math.floor(Math.random() * kavkazWordList.length);
  41. }
  42.  
  43. function createPhrase() {
  44.     var phrase = [],
  45.       i, j;
  46.     for ( i = 0; i < getRandomWordIndex()  + 2; i++) {
  47.         do {
  48.       j = getRandomWordIndex();
  49.     } while (j === prevWord);
  50.     prevWord = j;
  51.     phrase.push(kavkazWordList[j]);
  52.     }
  53.     prevWord = -1;
  54.     return phrase.join(' ') + kavkazPhraseEnd;
  55. }
  56.  
  57. function processPhoto (photos) {
  58.     var evObj;
  59.     if (photos.length === 0) {
  60.       setTimeout(doScript, reloadWaitTime);
  61.       return;
  62.     }
  63.    
  64.     evObj = document.createEvent('MouseEvents');
  65.     evObj.initEvent('mouseover', true, false);
  66.     photos[0].children[0].children[0].dispatchEvent(evObj);
  67.    
  68.     setTimeout(function () {
  69.       var photoLink = document.getElementsByClass("a", "gwt-shortcutMenu-iconlink-item")[0].children[0];
  70.       photoLink.click();
  71.     }, popupWaitTime);
  72.    
  73.     setTimeout(function () {
  74.       var commentBlock = document.getElementById("plp_cmtHId"),
  75.         commentEditField,
  76.         commentButton,
  77.         closeButton = document.getElementsByClass("div", "ic ic_i_close")[0],
  78.         usersOnlineButton = document.getElementsByClass("a", "sm fo4c_h_live-link fs-15")[0];
  79.        
  80.       photos.splice (0,1);
  81.        
  82.       if (commentBlock) {
  83.         commentEditField = commentBlock.children[1];
  84.         commentEditField.focus ();
  85.         commentEditField = commentBlock.children[0];
  86.         commentEditField.value = createPhrase();
  87.         setTimeout (function () {
  88.           commentButton = commentBlock.children[4].children[0];
  89.           if (commentButton) {
  90.             commentButton.click();  
  91.           }
  92.           closeButton.click();
  93.           setTimeout (function () {
  94.             processPhoto (photos);
  95.           }, closeWaitTime);
  96.         }, popupWaitTime);
  97.       } else if (document.getElementById ("addPrivateProfileButton") || document.getElementsByClass ("button-pro button-pro_disabled").length === 0) {
  98.         window.location.href = "http://odnoklassniki.ru/online";
  99.         setTimeout(doScript, reloadWaitTime);  
  100.       } else {
  101.         closeButton.click();
  102.         setTimeout (function () {
  103.           processPhoto (photos);
  104.         }, closeWaitTime);
  105.       }
  106.     }, photoLoadWaitTime);
  107. }
  108.  
  109. function fetchPhotos () {
  110.   var photos = document.getElementsByClass("a", "photoWrapper"),
  111.       usersOnlineButton = document.getElementsByClass("a", "sm fo4c_h_live-link fs-15")[0];
  112.   if (photos.length === 0) {
  113.       window.location.href = "http://odnoklassniki.ru/online";
  114.       setTimeout(doScript, reloadWaitTime);
  115.   } else {
  116.     processPhoto (photos);
  117.   }
  118. }
  119.    
  120. function doScript() {
  121.   var photos = document.getElementsByClass("a", "photoWrapper"),
  122.       cityLink = document.getElementById ("onSiteNowCityLink"),
  123.       cityEditField,
  124.       ageSelect = document.getElementsByClass("select", "isl isl__res isl__2num"),
  125.       minAgeSelect = ageSelect[0],
  126.       maxAgeSelect = ageSelect[1],
  127.       rand = Math.floor((Math.random()*cityList.length));
  128.  
  129.   minAgeSelect.value = minAge;
  130.   maxAgeSelect.value = maxAge;
  131.  
  132.   cityLink.click ();
  133.   cityEditField = document.getElementById ("field_city");
  134.   cityEditField.value = cityList[rand];
  135.  
  136.   checkbox = document.getElementById ("field_female");
  137.   checkbox.click ();
  138.   setTimeout(fetchPhotos, fetchWaitTime);
  139. }
  140.  
  141. setTimeout(doScript, initialWaitTime);// JavaScript Document
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement