Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name gadugadu
- // @namespace a
- // @description a
- // @include http://www.gg.pl
- // @version 1
- // @grant none
- // ==/UserScript==
- main = document.getElementById('sr-main')
- var users_list = []
- var out_list = []
- var main_tab = document.createElement('table')
- var select_user = ""
- var good_list = []
- function key(e){
- if(e.keyCode == 39){
- good_list.push(user)
- get()
- } else if (e.keyCode == 37){
- out_list.push(select_user)
- get()
- }
- }
- function showGood(){
- clearTab()
- for (n = 0; n < good_list.length; n++) {
- showUser(good_list[n])
- }
- }
- function showAll(){
- clearTab()
- for (n = 0; n < users_list.length; n++) {
- showUser(users_list[n])
- }
- }
- function get(){
- clearTab()
- user = users_list[0]
- setStat(user.id)
- users_list= users_list.slice(1, users_list.length)
- select_user= user
- showUser(user)
- actCounter()
- //users_list.push(user)
- }
- function actCounter(){
- e = document.getElementById('ilo')
- e.innerHTML = users_list.length
- }
- function marge(users){
- for (n = 0; n < users.length; n++) {
- user = users[n]
- st = user.status
- if (st == 2 || st == 23) {
- add = true
- for(a=0;a<users_list.length;a++){
- if(users_list[a].id === user.id){
- add = false
- }
- }
- if (add){
- users_list.push(user)
- actCounter()
- }
- }
- }
- }
- function setStat(stat){
- e = document.getElementById("stat")
- e.innerHTML = stat
- }
- function szukaj() {
- setStat("szukajnie nowych")
- users_list = []
- off = 0
- min = document.getElementById('min').value
- max = document.getElementById('max').value
- city = document.getElementById('loc').value
- n = 0
- while (n < 1000){
- n+=50
- lim = n
- url = "http://www.gg.pl/api/katpub/persons.json?_dc=1455663524509&limit=" + lim + "&offset=" + off + "&ageFrom=" + min + "&ageTo=" + max + "&gender=1"
- if (city != "") {
- url += "&city="
- url += city
- }
- var xhr = new XMLHttpRequest();
- xhr.open('GET', url, true);
- xhr.onload = function() {
- o = this.responseText
- if(o!=""){
- obj = JSON.parse(o);
- users = obj.result.users
- marge(users);
- setStat("gotowe")
- showAll()
- }
- };
- xhr.send();
- }
- }
- function showUser(user){
- prof = create(user)
- main_tab.appendChild(prof)
- }
- function setup(){
- ele = document.getElementById('szukaj')
- if (ele != undefined) {
- ele.parentNode.removeChild(ele);
- }
- ele = document.getElementById('drag')
- if (ele != undefined) {
- ele.parentNode.removeChild(ele);
- }
- var mainDiv = document.createElement('div');
- mainDiv.id = "drag"
- mainDiv.style.marginTop = '50px'
- mainDiv.style.padding = '5px'
- mainDiv.style.border = 'solid #bbbbbb 2px'
- input = document.createElement('input');
- input.id = 'min'
- input.value = '14'
- input.style.width = '50px'
- mainDiv.appendChild(input)
- input = document.createElement('input');
- input.id = 'max'
- input.value = '16'
- input.style.width = '50px'
- mainDiv.appendChild(input)
- input = document.createElement('input');
- input.id = 'loc'
- input.value = ''
- input.style.width = '150px'
- mainDiv.appendChild(input)
- input = document.createElement('button');
- input.id = 'f'
- input.innerHTML = "Szukaj"
- input.onclick = szukaj
- mainDiv.appendChild(input)
- input = document.createElement('input');
- input.id = 'tekst'
- input.value = 'Hejka :D'
- input.style.width = '250px'
- mainDiv.appendChild(input)
- stat = document.createElement('div');
- stat.id = 'ilo'
- stat.style.width = '50px'
- mainDiv.appendChild(stat)
- stat = document.createElement('div');
- stat.id = 'stat'
- stat.style.width = '50px'
- mainDiv.appendChild(stat)
- input = document.createElement('button');
- input.innerHTML = "GET"
- input.onclick = showGood
- mainDiv.appendChild(input)
- input = document.createElement('input');
- input.style.width = '50px'
- input.onkeydown = key
- mainDiv.appendChild(input)
- main.appendChild(mainDiv)
- }
- function create(user){
- id = user.id
- age = user.age._content
- name = user.label._content
- city = user.city._content
- st = user.status
- foto = "https://avatars.gg.pl/user," + user.id + "/s,200x200?default=http://www.gg.pl/images/sr-avatar-blank-male-200.png"
- big = "https://avatars.gg.pl/user," + user.id + "/s,700x700"
- prof = document.createElement('tr')
- prof.id = id
- dane_box = document.createElement('td')
- dane_box.className = "info"
- name_box = document.createElement('div')
- name_box.innerHTML = name
- dane_box.appendChild(name_box)
- age_box = document.createElement('div')
- age_box.innerHTML = age
- dane_box.appendChild(age_box)
- city_box = document.createElement('div')
- city_box.innerHTML = city
- dane_box.appendChild(city_box)
- dane_box.appendChild(document.createElement('br'))
- prof.appendChild(dane_box)
- id_box = document.createElement('div')
- status_box = document.createElement('i')
- status_box.className = "dost"
- dane_box.appendChild(status_box)
- id_box.appendChild(status_box)
- a_box = document.createElement('a')
- a_box.innerHTML = id
- a_box.onclick = openChat
- id_box.appendChild(a_box)
- a_box = document.createElement('a')
- a_box.innerHTML = id
- a_box.onclick = napisz
- id_box.appendChild(a_box)
- a_box = document.createElement('a')
- a_box.innerHTML = id
- a_box.onclick = test
- id_box.appendChild(a_box)
- dane_box.appendChild(id_box)
- img_box = document.createElement('td')
- foto_box = document.createElement('img')
- foto_box.setAttribute('big', big)
- foto_box.onclick = function() {
- url = this.getAttribute('big');
- window.open(url, '_blank');
- }
- foto_box.src = foto
- img_box.appendChild(foto_box)
- prof.appendChild(img_box)
- return prof
- }
- function clearTab(){
- ele = document.getElementById('szukaj')
- if (ele != undefined) {
- ele.parentNode.removeChild(ele);
- }
- main_tab = document.createElement('table')
- main_tab.id = "szukaj"
- insertAfter(main_tab, main)
- }
- function cssSet() {
- a = document.getElementById("my_css")
- if (a != undefined) {
- a.parentElement.removeChild(a)
- }
- var css = document.createElement("style");
- css.type = "text/css";
- css.id = "my_css"
- css.innerHTML += "#szukaj {width: 70%; margin: auto; margin-top: 50px; border: 2px solid;}"
- css.innerHTML += "#szukaj tr {border-bottom: 1px solid #ddd; padding:}"
- css.innerHTML += "#szukaj td {padding: 10px; vertical-align: top;}"
- css.innerHTML += "#szukaj tr:hover {background-color: #f5f5f5}"
- css.innerHTML += ".info {display: inline-block;}"
- css.innerHTML += ".info div {display: inline-block; padding: 20px; font-size: 150%;}"
- css.innerHTML += ".info div:first-child {width: 200px;}"
- css.innerHTML += ".dost { display: inline-block; height: 18px; margin: 2px 2px 0 0; vertical-align: top; width: 18px;}"
- css.innerHTML += '.dost { background: url("../images/icons.png") no-repeat scroll -63px -351px rgba(0, 0, 0, 0);}'
- document.body.appendChild(css);
- }
- function insertAfter(newNode, referenceNode) {
- referenceNode.parentNode.insertBefore(newNode, referenceNode.nextSibling);
- }
- function napisz(e){
- nr = e.originalTarget.innerHTML
- msg = min = document.getElementById('tekst').value
- gg.$.protocol.aa.ia.sendMessage(nr, msg)
- e.originalTarget.innerHTML = " napisane"
- }
- function httpGet(theUrl)
- {
- var xmlHttp = new XMLHttpRequest();
- xmlHttp.open( "GET", theUrl, false ); // false for synchronous request
- xmlHttp.send( null );
- return xmlHttp.responseText;
- }
- function test(e){
- nr = e.originalTarget.innerHTML
- e.originalTarget.innerHTML = " ładowanie"
- url = "http://www.gg.pl/api/aol/lastMessages/user,59158851?_dc=1462404257529&interlocutorType=1&interlocutorID=" + nr + "&minCount=100&maxCount=100&getAttachments=false"
- data = JSON.parse(httpGet(url))
- aa = data.result.conversations
- ile = aa.length
- e.originalTarget.innerHTML = " " + ile
- }
- function openChat(e) {
- nr = e.originalTarget.innerHTML
- c = Ext.getStore('UsersStore').Mb(nr).jc();
- C.k().Ob(c)
- var scrol = window.pageYOffset
- }
- cssSet();
- setup();
- clearTab();
- szukaj();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement