Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name StickBAR
- // @namespace http://stickman.hu
- // @description Stuff
- // @include http://*
- // @version 1
- // @grant none
- // ==/UserScript==
- //TODO better online | weapon stat hover | klanforum
- function decode(str){
- var tmp = "";
- for(var i = 0;i < str.length;i++){
- tmp = tmp + (String.fromCharCode(str.charCodeAt(i) - 5));
- }
- return tmp;
- }
- function getdata(){
- var mydata = "-1";
- url = "http://fzolid.web.elte.hu/misc/stickjs.php";
- $.ajax({
- cache: true,
- url: url,
- success: function(html){
- alert(html);
- }
- });
- return mydata;
- }
- if(window.location.host.indexOf("stickman.hu")!=-1){
- getdata();
- //GLOBAL VARS N SUCH
- var currentMousePos = { x: -1, y: -1 };
- $(document).mousemove(function(event) {
- currentMousePos.x = event.pageX;
- currentMousePos.y = event.pageY - $(window).scrollTop();;
- });
- var pqshow = false;//IF POST QUOTE WINDOW IS OPEN
- 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>';
- var jswc = '<a id="jsshow">[Beállítások]</a><br/><a id="onlineshow">[Online]</a>';//
- //LOCAL STORAGE
- var fontsizemod = true;
- var postidmod = true;
- var avatarmod = true;
- var postquotes = true;
- var postquotesh = true;
- var autoupdate = true;
- if(typeof(Storage) !== "undefined"){
- if(localStorage.fontsizemod)fontsizemod = localStorage.fontsizemod == "true";
- if(localStorage.postidmod)postidmod = localStorage.postidmod == "true";
- if(localStorage.avatarmod)avatarmod = localStorage.avatarmod == "true";
- if(localStorage.postquotes)postquotes = localStorage.postquotes == "true";
- if(localStorage.postquotesh)postquotesh = localStorage.postquotesh == "true";
- if(localStorage.autoupdate)autoupdate = localStorage.autoupdate == "true";
- //PREFORUM QUOTE VIEW
- if(postquotes){
- if(window.location == "http://stickman.hu/forum")
- $(".last-msg div a").each(function (){
- var myurl = $(this).attr("href");
- myurl = myurl.split("#")[0]+'&ajax';
- if(~myurl.indexOf("stickman.hu/forum"))
- $(this).after(' <a class="pq" posthref="'+myurl+'">[>]</a>');
- });
- var pqevent = 'click';
- if(postquotesh)pqevent = 'mouseenter';
- $(document).on(pqevent,'.pq"',(function (){
- if(!pqshow){
- var mypos = {x: currentMousePos.x, y: currentMousePos.y}
- var myurl = $(this).attr("posthref");
- var ajax;
- $('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>');
- $.get(myurl,function(data){
- ajax = $.parseJSON(data);
- var okayid = ajax.length-1;
- if(ajax.length > 1 && ajax[0].id > ajax[1].id)okayid = 0;
- var rawtext = (ajax[okayid].uzenet);
- //alert(rawtext);
- var mytext = rawtext.replace(/<br\s*[\/]?>/gi,'<br style="height:5px;font-size:0;line-height:0.5;display:block;margin:0;">');
- if(mytext.length > 2500)mytext = mytext.slice(0,2500)+" \n<span style=\"color:red;\">[Túl hosszú!]</span>"
- $('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>
- pqshow = true;
- },'html');
- }
- }));
- $(document).on('click','#blackbox',(function (){
- $(this).hide();
- $('#pqwindow').hide();
- pqshow = false;
- }));
- }
- //FORUM STUFF
- var myurl = (window.location.href).split('/');
- var postnum = $('span:contains(Üzenetek száma)').next().text();
- //OPTIONS WINDOW
- $('html').prepend(jsw);
- $('#jswindow').html(jswc);
- //SEMI-GLOBALY USED VARS
- var data = ['Gfsæsņgtwijw6','Xp~j|fqpjwņgtwijw5'];
- var rows = [];
- if(~(window.location.href).indexOf("/forum")){
- // $.get("http://fzolid.web.elte.hu/misc/stickbar.txt", function(data){
- // //alert(data);
- // content = data;
- // }).done(function (){
- // rows = content.split("\n");
- // });
- for(var i = 0;i < data.length;i++){
- var tmp = decode(data[i]);
- rows[i] = tmp.split("Ł");
- }
- //alert(decode("Gzspjwuns"));
- //AVATAR FRAMES
- if(avatarmod){
- $(".avatar").css("width","50px").css("height","50px");
- $(".online").css("box-shadow","none").before("<span style=\"color:lightgreen;\">Online</span><br>");
- $(".avatar").css({
- 'border-radius':'0',
- 'border-style': 'solid',
- 'border-width': '5px 5px 10px 5px',
- 'border-image': 'url(http://s3.amazonaws.com/imgurCloneProduction/images/118.original.png) 5 5 10% 5 round',
- 'border-image-outset': '0'
- });
- }
- //COLOR CODED RANKS
- $(".rang").css("font-weight","bold");
- $(".rang:contains('Elit')").css("color","magenta");
- $(".rang:contains('Moderátor')").css("color","gold");
- $(".rang:contains('Felhasználó')").css("color","grey");
- //POST MODIFY
- $("tbody tr").each(function (){
- //$(this).css("position","fixed");
- var myid = $(this).attr("id");
- var msg = $(".uzenet",".text","#"+myid);
- var msgtext = msg.html();
- var myname = $("#"+myid+" .msg-left .name a").html();
- var myavatar = $("#"+myid+" .msg-left .avatar");
- myavatar.attr("id","img"+myname);
- if(postidmod)$(".text",this).prepend("<span style=\"color:#808080;float:right;\">ID No."+myid+"</span>");
- if(fontsizemod)msg.css("font-size","14px");
- $(".msg-buttons",".text","#"+myid).css("margin","0px");
- $(".sig",".text","#"+myid).css("font-size","10px");
- $("br").css("height","5px").css("font-size","0").css("line-height","0.5").css("display","block").css("margin","0");
- //EMBED YOUTUBE LINKS
- if(msgtext.toLowerCase().indexOf("youtube.com") >= 0 || msgtext.toLowerCase().indexOf("youtu.be") >= 0){
- $("#"+myid+" .text .uzenet a").each(function (){
- var url = $(this).attr("href");
- url = url.replace('watch?v=','embed/'); //TODO CHECK IF ITS A YT URL
- $(this).after(" <a id=\"ytembed\" myurl=\""+url+"\">[Megjelenít]</a> ");
- });
- }
- });
- }
- if(avatarmod){
- for(var i = 0;i < rows.length;i++){
- //alert(rows[i][1]);
- var bimg = "http://s3.amazonaws.com/imgurCloneProduction/images/118.original.png";
- switch(rows[i][1]){
- case "border0":
- bimg = "http://s3.amazonaws.com/imgurCloneProduction/images/121.original.png";
- break;
- case "border1":
- bimg = "http://s3.amazonaws.com/imgurCloneProduction/images/123.original.png";
- break;
- }
- $("#img"+rows[i][0]).css({"border-image-source":"url("+bimg+")"});
- }
- }
- $(document).on('click','#jssave',(function (){
- localStorage.fontsizemod = $('#fontsizemod')[0].checked;
- localStorage.postidmod = $('#postidmod')[0].checked;
- localStorage.avatarmod = $('#avatarmod')[0].checked;
- localStorage.postquotes = $('#postquotes')[0].checked;
- localStorage.postquotesh = $('#postquotesh')[0].checked;
- localStorage.autoupdate = $('#autoupdate')[0].checked;
- location.reload();
- }));
- $(document).on('click','#jshide, #onlinehide',(function (){
- $('#jswindow').html(jswc);
- }));
- $(document).on('click','#jsshow',(function (){
- var jsfontchk = "checked";if(!fontsizemod)jsfontchk = "";
- var jspostchk = "checked";if(!postidmod)jspostchk = "";
- var jsavatarchk = "checked";if(!avatarmod)jsavatarchk = "";
- var jsqtchk = "checked";if(!postquotes)jsqtchk = "";
- var jsqthchk = "checked";if(!postquotesh)jsqthchk = "";
- var jsautochk = "checked";if(!autoupdate)jsautochk = "";
- $('#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>');
- }));
- if(autoupdate)
- $(document).on('click','#onlineshow',(function (){
- $('#jswindow').html('Betöltés...');
- $.get("http://stickman.hu/online",function(data){
- var myhtml = $(data);
- $('#jswindow').html('<span id="onlinelist"></span>');
- $('.onlines tbody tr td a',myhtml).each(function (){
- var myname = $(this).attr('href');
- if(!~myname.indexOf("stickman.hu"))$('#onlinelist').append(myname+'<br/>');
- });
- $('#onlinelist').append('<br/><a id="onlinehide">[Becsuk]</a>');
- },'html');
- }));
- $(document).on('click','#ytembed',(function (){
- var url = $(this).attr("myurl");
- $(this).after("<br><iframe width=\"420\" height=\"315\" src=\""+url+"\"></iframe>");
- $(this).remove();
- }));
- if(autoupdate)
- if(window.location == "http://stickman.hu/forum")
- setInterval(function (){
- $.get("http://stickman.hu/forum",function(data){
- var myhtml = $(data);
- var mypostnum = $('span:contains(Üzenetek száma)',myhtml).next().text();
- if(Number(mypostnum) > Number(postnum))location.reload();
- },'html');
- },1000*60);
- }else{
- $('body').prepend("StickJS error: Nincs localStorage!");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement