Advertisement
Guest User

Untitled

a guest
Aug 30th, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.47 KB | None | 0 0
  1. // ==UserScript==
  2. // @name gadugadu
  3. // @namespace a
  4. // @description a
  5. // @include http://www.gg.pl
  6. // @version 1
  7. // @grant none
  8. // ==/UserScript==
  9.  
  10. main = document.getElementById('sr-main')
  11. var users_list = []
  12. var out_list = []
  13. var main_tab = document.createElement('table')
  14. var select_user = ""
  15. var good_list = []
  16.  
  17. function key(e){
  18. if(e.keyCode == 39){
  19. good_list.push(user)
  20. get()
  21. } else if (e.keyCode == 37){
  22. out_list.push(select_user)
  23. get()
  24. }
  25. }
  26.  
  27. function showGood(){
  28. clearTab()
  29. for (n = 0; n < good_list.length; n++) {
  30. showUser(good_list[n])
  31.  
  32. }
  33. }
  34.  
  35.  
  36. function showAll(){
  37. clearTab()
  38. for (n = 0; n < users_list.length; n++) {
  39. showUser(users_list[n])
  40.  
  41. }
  42. }
  43.  
  44.  
  45. function get(){
  46. clearTab()
  47. user = users_list[0]
  48. setStat(user.id)
  49. users_list= users_list.slice(1, users_list.length)
  50. select_user= user
  51. showUser(user)
  52. actCounter()
  53. //users_list.push(user)
  54. }
  55.  
  56. function actCounter(){
  57. e = document.getElementById('ilo')
  58. e.innerHTML = users_list.length
  59. }
  60.  
  61. function marge(users){
  62. for (n = 0; n < users.length; n++) {
  63. user = users[n]
  64. st = user.status
  65. if (st == 2 || st == 23) {
  66. add = true
  67. for(a=0;a<users_list.length;a++){
  68. if(users_list[a].id === user.id){
  69. add = false
  70. }
  71. }
  72. if (add){
  73. users_list.push(user)
  74. actCounter()
  75. }
  76.  
  77. }
  78. }
  79. }
  80.  
  81. function setStat(stat){
  82. e = document.getElementById("stat")
  83. e.innerHTML = stat
  84. }
  85.  
  86.  
  87. function szukaj() {
  88. setStat("szukajnie nowych")
  89. users_list = []
  90. off = 0
  91. min = document.getElementById('min').value
  92. max = document.getElementById('max').value
  93. city = document.getElementById('loc').value
  94.  
  95. n = 0
  96. while (n < 1000){
  97. n+=50
  98. lim = n
  99. url = "http://www.gg.pl/api/katpub/persons.json?_dc=1455663524509&limit=" + lim + "&offset=" + off + "&ageFrom=" + min + "&ageTo=" + max + "&gender=1"
  100. if (city != "") {
  101. url += "&city="
  102. url += city
  103. }
  104. var xhr = new XMLHttpRequest();
  105. xhr.open('GET', url, true);
  106. xhr.onload = function() {
  107. o = this.responseText
  108. if(o!=""){
  109. obj = JSON.parse(o);
  110.  
  111. users = obj.result.users
  112. marge(users);
  113. setStat("gotowe")
  114. showAll()
  115.  
  116. }
  117. };
  118. xhr.send();
  119. }
  120. }
  121.  
  122. function showUser(user){
  123. prof = create(user)
  124. main_tab.appendChild(prof)
  125. }
  126.  
  127. function setup(){
  128. ele = document.getElementById('szukaj')
  129. if (ele != undefined) {
  130. ele.parentNode.removeChild(ele);
  131. }
  132.  
  133. ele = document.getElementById('drag')
  134. if (ele != undefined) {
  135. ele.parentNode.removeChild(ele);
  136. }
  137.  
  138. var mainDiv = document.createElement('div');
  139. mainDiv.id = "drag"
  140.  
  141.  
  142.  
  143. mainDiv.style.marginTop = '50px'
  144. mainDiv.style.padding = '5px'
  145. mainDiv.style.border = 'solid #bbbbbb 2px'
  146.  
  147.  
  148. input = document.createElement('input');
  149. input.id = 'min'
  150. input.value = '14'
  151. input.style.width = '50px'
  152. mainDiv.appendChild(input)
  153.  
  154. input = document.createElement('input');
  155. input.id = 'max'
  156. input.value = '16'
  157. input.style.width = '50px'
  158. mainDiv.appendChild(input)
  159.  
  160. input = document.createElement('input');
  161. input.id = 'loc'
  162. input.value = ''
  163. input.style.width = '150px'
  164. mainDiv.appendChild(input)
  165.  
  166. input = document.createElement('button');
  167. input.id = 'f'
  168. input.innerHTML = "Szukaj"
  169. input.onclick = szukaj
  170. mainDiv.appendChild(input)
  171.  
  172. input = document.createElement('input');
  173. input.id = 'tekst'
  174. input.value = 'Hejka :D'
  175. input.style.width = '250px'
  176. mainDiv.appendChild(input)
  177.  
  178.  
  179. stat = document.createElement('div');
  180. stat.id = 'ilo'
  181. stat.style.width = '50px'
  182. mainDiv.appendChild(stat)
  183.  
  184. stat = document.createElement('div');
  185. stat.id = 'stat'
  186. stat.style.width = '50px'
  187. mainDiv.appendChild(stat)
  188.  
  189. input = document.createElement('button');
  190. input.innerHTML = "GET"
  191. input.onclick = showGood
  192. mainDiv.appendChild(input)
  193.  
  194.  
  195. input = document.createElement('input');
  196. input.style.width = '50px'
  197. input.onkeydown = key
  198. mainDiv.appendChild(input)
  199.  
  200. main.appendChild(mainDiv)
  201. }
  202.  
  203. function create(user){
  204. id = user.id
  205. age = user.age._content
  206. name = user.label._content
  207. city = user.city._content
  208. st = user.status
  209. foto = "https://avatars.gg.pl/user," + user.id + "/s,200x200?default=http://www.gg.pl/images/sr-avatar-blank-male-200.png"
  210. big = "https://avatars.gg.pl/user," + user.id + "/s,700x700"
  211. prof = document.createElement('tr')
  212. prof.id = id
  213.  
  214. dane_box = document.createElement('td')
  215. dane_box.className = "info"
  216.  
  217. name_box = document.createElement('div')
  218. name_box.innerHTML = name
  219. dane_box.appendChild(name_box)
  220.  
  221.  
  222.  
  223. age_box = document.createElement('div')
  224. age_box.innerHTML = age
  225. dane_box.appendChild(age_box)
  226.  
  227.  
  228.  
  229. city_box = document.createElement('div')
  230. city_box.innerHTML = city
  231. dane_box.appendChild(city_box)
  232.  
  233. dane_box.appendChild(document.createElement('br'))
  234.  
  235.  
  236. prof.appendChild(dane_box)
  237.  
  238. id_box = document.createElement('div')
  239.  
  240. status_box = document.createElement('i')
  241. status_box.className = "dost"
  242. dane_box.appendChild(status_box)
  243. id_box.appendChild(status_box)
  244.  
  245. a_box = document.createElement('a')
  246. a_box.innerHTML = id
  247. a_box.onclick = openChat
  248. id_box.appendChild(a_box)
  249.  
  250.  
  251. a_box = document.createElement('a')
  252. a_box.innerHTML = id
  253. a_box.onclick = napisz
  254. id_box.appendChild(a_box)
  255.  
  256.  
  257. a_box = document.createElement('a')
  258. a_box.innerHTML = id
  259. a_box.onclick = test
  260. id_box.appendChild(a_box)
  261.  
  262.  
  263.  
  264. dane_box.appendChild(id_box)
  265.  
  266. img_box = document.createElement('td')
  267. foto_box = document.createElement('img')
  268. foto_box.setAttribute('big', big)
  269. foto_box.onclick = function() {
  270. url = this.getAttribute('big');
  271. window.open(url, '_blank');
  272. }
  273.  
  274. foto_box.src = foto
  275. img_box.appendChild(foto_box)
  276. prof.appendChild(img_box)
  277.  
  278.  
  279.  
  280. return prof
  281.  
  282.  
  283. }
  284.  
  285. function clearTab(){
  286. ele = document.getElementById('szukaj')
  287. if (ele != undefined) {
  288. ele.parentNode.removeChild(ele);
  289. }
  290. main_tab = document.createElement('table')
  291. main_tab.id = "szukaj"
  292. insertAfter(main_tab, main)
  293. }
  294.  
  295. function cssSet() {
  296. a = document.getElementById("my_css")
  297. if (a != undefined) {
  298. a.parentElement.removeChild(a)
  299. }
  300.  
  301. var css = document.createElement("style");
  302. css.type = "text/css";
  303. css.id = "my_css"
  304. css.innerHTML += "#szukaj {width: 70%; margin: auto; margin-top: 50px; border: 2px solid;}"
  305. css.innerHTML += "#szukaj tr {border-bottom: 1px solid #ddd; padding:}"
  306. css.innerHTML += "#szukaj td {padding: 10px; vertical-align: top;}"
  307. css.innerHTML += "#szukaj tr:hover {background-color: #f5f5f5}"
  308. css.innerHTML += ".info {display: inline-block;}"
  309. css.innerHTML += ".info div {display: inline-block; padding: 20px; font-size: 150%;}"
  310. css.innerHTML += ".info div:first-child {width: 200px;}"
  311.  
  312. css.innerHTML += ".dost { display: inline-block; height: 18px; margin: 2px 2px 0 0; vertical-align: top; width: 18px;}"
  313. css.innerHTML += '.dost { background: url("../images/icons.png") no-repeat scroll -63px -351px rgba(0, 0, 0, 0);}'
  314. document.body.appendChild(css);
  315. }
  316.  
  317. function insertAfter(newNode, referenceNode) {
  318. referenceNode.parentNode.insertBefore(newNode, referenceNode.nextSibling);
  319. }
  320.  
  321. function napisz(e){
  322. nr = e.originalTarget.innerHTML
  323. msg = min = document.getElementById('tekst').value
  324. gg.$.protocol.aa.ia.sendMessage(nr, msg)
  325. e.originalTarget.innerHTML = " napisane"
  326. }
  327.  
  328. function httpGet(theUrl)
  329. {
  330. var xmlHttp = new XMLHttpRequest();
  331. xmlHttp.open( "GET", theUrl, false ); // false for synchronous request
  332. xmlHttp.send( null );
  333. return xmlHttp.responseText;
  334. }
  335.  
  336.  
  337. function test(e){
  338. nr = e.originalTarget.innerHTML
  339. e.originalTarget.innerHTML = " ładowanie"
  340. url = "http://www.gg.pl/api/aol/lastMessages/user,59158851?_dc=1462404257529&interlocutorType=1&interlocutorID=" + nr + "&minCount=100&maxCount=100&getAttachments=false"
  341. data = JSON.parse(httpGet(url))
  342. aa = data.result.conversations
  343. ile = aa.length
  344. e.originalTarget.innerHTML = " " + ile
  345. }
  346.  
  347.  
  348. function openChat(e) {
  349. nr = e.originalTarget.innerHTML
  350. c = Ext.getStore('UsersStore').Mb(nr).jc();
  351. C.k().Ob(c)
  352. var scrol = window.pageYOffset
  353.  
  354. }
  355.  
  356.  
  357. cssSet();
  358. setup();
  359. clearTab();
  360. szukaj();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement