Advertisement
Guest User

Untitled

a guest
May 14th, 2017
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name        StickBAR
  3. // @namespace   http://stickman.hu
  4. // @description Stuff
  5. // @include     http://*
  6. // @version     1
  7. // @grant       none
  8. // ==/UserScript==
  9.  
  10. //TODO  better online | weapon stat hover | klanforum
  11.  
  12. function decode(str){
  13.     var tmp = "";
  14.     for(var i = 0;i < str.length;i++){
  15.         tmp = tmp + (String.fromCharCode(str.charCodeAt(i) - 5));
  16.     }
  17.     return tmp;
  18. }
  19.  
  20. function getdata(){
  21.     var mydata = "-1";
  22.    
  23.     url = "http://fzolid.web.elte.hu/misc/stickjs.php";
  24.     $.ajax({
  25.         cache: true,
  26.         url: url,
  27.         success: function(html){
  28.             alert(html);
  29.            
  30.            
  31.         }
  32.     });
  33.    
  34.     return mydata;
  35. }
  36.  
  37. if(window.location.host.indexOf("stickman.hu")!=-1){
  38.    
  39.     getdata();
  40.    
  41.     //GLOBAL VARS N SUCH
  42.     var currentMousePos = { x: -1, y: -1 };
  43.     $(document).mousemove(function(event) {
  44.         currentMousePos.x = event.pageX;
  45.         currentMousePos.y = event.pageY - $(window).scrollTop();;
  46.     });
  47.    
  48.     var pqshow = false;//IF POST QUOTE WINDOW IS OPEN
  49.     var jsw = '<div id="jswindow" style="z-index:9001;padding:10px;color:white;font-family:Arial;text-align:right;position:fixed;right:0px;top:0px;width:20vw;height:auto;"></div>';
  50.     var jswc = '<a id="jsshow">[Beállítások]</a><br/><a id="onlineshow">[Online]</a>';//
  51.    
  52.     //LOCAL STORAGE
  53.     var fontsizemod = true;
  54.     var postidmod = true;
  55.     var avatarmod = true;
  56.     var postquotes = true;
  57.     var postquotesh = true;
  58.     var autoupdate = true;
  59.     if(typeof(Storage) !== "undefined"){
  60.         if(localStorage.fontsizemod)fontsizemod = localStorage.fontsizemod == "true";
  61.         if(localStorage.postidmod)postidmod = localStorage.postidmod == "true";
  62.         if(localStorage.avatarmod)avatarmod = localStorage.avatarmod == "true";
  63.         if(localStorage.postquotes)postquotes = localStorage.postquotes == "true";
  64.         if(localStorage.postquotesh)postquotesh = localStorage.postquotesh == "true";
  65.         if(localStorage.autoupdate)autoupdate = localStorage.autoupdate == "true";
  66.        
  67.        
  68.        
  69.         //PREFORUM QUOTE VIEW
  70.         if(postquotes){
  71.             if(window.location == "http://stickman.hu/forum")
  72.             $(".last-msg div a").each(function (){
  73.                 var myurl = $(this).attr("href");
  74.                 myurl = myurl.split("#")[0]+'&ajax';
  75.                 if(~myurl.indexOf("stickman.hu/forum"))
  76.                     $(this).after(' <a class="pq" posthref="'+myurl+'">[>]</a>');
  77.                
  78.             });
  79.            
  80.             var pqevent = 'click';
  81.             if(postquotesh)pqevent = 'mouseenter';
  82.             $(document).on(pqevent,'.pq"',(function (){
  83.                 if(!pqshow){
  84.                     var mypos = {x: currentMousePos.x, y: currentMousePos.y}
  85.                     var myurl = $(this).attr("posthref");
  86.                     var ajax;
  87.                    
  88.                     $('html').prepend('<div style="position:fixed;float:left;left:0;top:0;background-color:#000000;opacity:0.6;width:100vw;height:100vh;" id="blackbox"></div>');
  89.                    
  90.                     $.get(myurl,function(data){
  91.                         ajax = $.parseJSON(data);
  92.                        
  93.                         var okayid = ajax.length-1;
  94.                         if(ajax.length > 1 && ajax[0].id > ajax[1].id)okayid = 0;
  95.                        
  96.                         var rawtext = (ajax[okayid].uzenet);
  97.                         //alert(rawtext);
  98.                         var mytext = rawtext.replace(/<br\s*[\/]?>/gi,'<br style="height:5px;font-size:0;line-height:0.5;display:block;margin:0;">');
  99.                         if(mytext.length > 2500)mytext = mytext.slice(0,2500)+" \n<span style=\"color:red;\">[Túl hosszú!]</span>"
  100.                        
  101.                         $('html').prepend('<div id="pqwindow" style="padding:10px;color:white;font-family:Segoe UI, Arial, sans-serif;background-color:#222222;min-width:300px;max-width:600px;max-height:200px;border:5px #f55810 solid;z-index:9001;position:fixed;top:'+(mypos.y)+'px;left:'+(mypos.x - 200)+'px;"><div style="width:100%;max-height:200px;overflow:auto;">'+mytext+'</div></div>');//<iframe width="600" height="200" src="'+myurl+'"></iframe>
  102.                        
  103.                         pqshow = true;
  104.                    
  105.                     },'html');
  106.                    
  107.                 }
  108.             }));
  109.            
  110.             $(document).on('click','#blackbox',(function (){
  111.                 $(this).hide();
  112.                 $('#pqwindow').hide();
  113.                 pqshow = false;
  114.  
  115.             }));
  116.         }
  117.        
  118.        
  119.         //FORUM STUFF
  120.         var myurl = (window.location.href).split('/');
  121.         var postnum = $('span:contains(Üzenetek száma)').next().text();
  122.        
  123.        
  124.         //OPTIONS WINDOW
  125.         $('html').prepend(jsw);
  126.         $('#jswindow').html(jswc);
  127.        
  128.        
  129.         //SEMI-GLOBALY USED VARS
  130.         var data = ['Gfsæsņgtwijw6','Xp~j|fqpjwņgtwijw5'];
  131.  
  132.         var rows = [];
  133.        
  134.         if(~(window.location.href).indexOf("/forum")){
  135.            
  136.             // $.get("http://fzolid.web.elte.hu/misc/stickbar.txt", function(data){
  137.                 // //alert(data);
  138.                 // content = data;
  139.             // }).done(function (){
  140.                 // rows = content.split("\n");
  141.             // });
  142.            
  143.             for(var i = 0;i < data.length;i++){
  144.                 var tmp = decode(data[i]);
  145.                 rows[i] = tmp.split("Ł");
  146.                
  147.             }
  148.            
  149.             //alert(decode("Gzspjwuns"));
  150.            
  151.             //AVATAR FRAMES
  152.             if(avatarmod){
  153.                 $(".avatar").css("width","50px").css("height","50px");
  154.                 $(".online").css("box-shadow","none").before("<span style=\"color:lightgreen;\">Online</span><br>");
  155.                 $(".avatar").css({
  156.                     'border-radius':'0',
  157.                     'border-style': 'solid',
  158.                     'border-width': '5px 5px 10px 5px',
  159.                     'border-image': 'url(http://s3.amazonaws.com/imgurCloneProduction/images/118.original.png) 5 5 10% 5 round',
  160.                     'border-image-outset': '0'
  161.                    
  162.                 });
  163.             }
  164.            
  165.                
  166.                
  167.             //COLOR CODED RANKS
  168.             $(".rang").css("font-weight","bold");
  169.             $(".rang:contains('Elit')").css("color","magenta");
  170.             $(".rang:contains('Moderátor')").css("color","gold");
  171.             $(".rang:contains('Felhasználó')").css("color","grey");
  172.            
  173.             //POST MODIFY
  174.             $("tbody tr").each(function (){
  175.                 //$(this).css("position","fixed");
  176.                 var myid = $(this).attr("id");
  177.                 var msg = $(".uzenet",".text","#"+myid);
  178.                 var msgtext = msg.html();
  179.                 var myname = $("#"+myid+" .msg-left .name a").html();
  180.                 var myavatar = $("#"+myid+" .msg-left .avatar");
  181.                
  182.                 myavatar.attr("id","img"+myname);
  183.                
  184.                 if(postidmod)$(".text",this).prepend("<span style=\"color:#808080;float:right;\">ID No."+myid+"</span>");
  185.                 if(fontsizemod)msg.css("font-size","14px");
  186.                 $(".msg-buttons",".text","#"+myid).css("margin","0px");
  187.                 $(".sig",".text","#"+myid).css("font-size","10px");
  188.                 $("br").css("height","5px").css("font-size","0").css("line-height","0.5").css("display","block").css("margin","0");
  189.                
  190.                 //EMBED YOUTUBE LINKS
  191.                 if(msgtext.toLowerCase().indexOf("youtube.com") >= 0 || msgtext.toLowerCase().indexOf("youtu.be") >= 0){
  192.                     $("#"+myid+" .text .uzenet a").each(function (){
  193.                         var url = $(this).attr("href");
  194.                         url = url.replace('watch?v=','embed/'); //TODO CHECK IF ITS A YT URL
  195.                         $(this).after(" <a id=\"ytembed\" myurl=\""+url+"\">[Megjelenít]</a> ");
  196.                        
  197.                     });
  198.                 }
  199.             });
  200.         }
  201.        
  202.         if(avatarmod){
  203.             for(var i = 0;i < rows.length;i++){
  204.                 //alert(rows[i][1]);
  205.                 var bimg = "http://s3.amazonaws.com/imgurCloneProduction/images/118.original.png";
  206.                 switch(rows[i][1]){
  207.                     case "border0":
  208.                         bimg = "http://s3.amazonaws.com/imgurCloneProduction/images/121.original.png";
  209.                     break;
  210.                     case "border1":
  211.                         bimg = "http://s3.amazonaws.com/imgurCloneProduction/images/123.original.png";
  212.                     break;
  213.                    
  214.                 }
  215.                 $("#img"+rows[i][0]).css({"border-image-source":"url("+bimg+")"});
  216.                    
  217.             }
  218.         }
  219.        
  220.        
  221.         $(document).on('click','#jssave',(function (){
  222.             localStorage.fontsizemod = $('#fontsizemod')[0].checked;
  223.             localStorage.postidmod = $('#postidmod')[0].checked;
  224.             localStorage.avatarmod = $('#avatarmod')[0].checked;
  225.             localStorage.postquotes = $('#postquotes')[0].checked;
  226.             localStorage.postquotesh = $('#postquotesh')[0].checked;
  227.             localStorage.autoupdate = $('#autoupdate')[0].checked;
  228.             location.reload();
  229.            
  230.         }));
  231.        
  232.         $(document).on('click','#jshide, #onlinehide',(function (){
  233.             $('#jswindow').html(jswc);
  234.            
  235.         }));
  236.        
  237.         $(document).on('click','#jsshow',(function (){
  238.             var jsfontchk = "checked";if(!fontsizemod)jsfontchk = "";
  239.             var jspostchk = "checked";if(!postidmod)jspostchk = "";
  240.             var jsavatarchk = "checked";if(!avatarmod)jsavatarchk = "";
  241.             var jsqtchk = "checked";if(!postquotes)jsqtchk = "";
  242.             var jsqthchk = "checked";if(!postquotesh)jsqthchk = "";
  243.             var jsautochk = "checked";if(!autoupdate)jsautochk = "";
  244.             $('#jswindow').html('<form id="jsform" action=""><input type="checkbox" id="fontsizemod" name="fontsizemod" value="True" '+jsfontchk+'>Kisebb betűméret<br/><input type="checkbox" name="postidmod" id="postidmod" value="True" '+jspostchk+'>Poszt ID mutatása<br/><input type="checkbox" name="avatarmod" id="avatarmod" value="True" '+jsavatarchk+'>Alternativ avatarok<br/><input type="checkbox" name="postquotes" id="postquotes" value="True" '+jsqtchk+'>Poszt gyorsnézet<br/><input type="checkbox" name="postquotesh" id="postquotesh" value="True" '+jsqthchk+'>Gyorsnézet hover<br/><input type="checkbox" name="autoupdate" id="autoupdate" value="True" '+jsautochk+'>Auto-frissítés</form><br/><a id="jssave">[Mentés]</a><br/><a id="jshide">[Becsuk]</a>');
  245.            
  246.         }));
  247.        
  248.         if(autoupdate)
  249.         $(document).on('click','#onlineshow',(function (){
  250.             $('#jswindow').html('Betöltés...');
  251.             $.get("http://stickman.hu/online",function(data){
  252.                 var myhtml = $(data);
  253.                 $('#jswindow').html('<span id="onlinelist"></span>');
  254.                 $('.onlines tbody tr td a',myhtml).each(function (){
  255.                 var myname = $(this).attr('href');
  256.                 if(!~myname.indexOf("stickman.hu"))$('#onlinelist').append(myname+'<br/>');
  257.             });
  258.             $('#onlinelist').append('<br/><a id="onlinehide">[Becsuk]</a>');
  259.            
  260.             },'html');
  261.            
  262.         }));
  263.        
  264.         $(document).on('click','#ytembed',(function (){
  265.             var url = $(this).attr("myurl");
  266.             $(this).after("<br><iframe width=\"420\" height=\"315\" src=\""+url+"\"></iframe>");
  267.             $(this).remove();
  268.            
  269.         }));
  270.        
  271.         if(autoupdate)
  272.         if(window.location == "http://stickman.hu/forum")
  273.         setInterval(function (){
  274.             $.get("http://stickman.hu/forum",function(data){
  275.                 var myhtml = $(data);
  276.                 var mypostnum = $('span:contains(Üzenetek száma)',myhtml).next().text();
  277.                 if(Number(mypostnum) > Number(postnum))location.reload();
  278.                
  279.             },'html');
  280.            
  281.         },1000*60);
  282.        
  283.     }else{
  284.         $('body').prepend("StickJS error: Nincs localStorage!");
  285.        
  286.     }
  287.    
  288.    
  289.    
  290. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement