Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name Friends
- // @version 1
- // @description The long awaited Friends script!
- // @include http://tagpro-*.koalabeast.com*
- // @require //cdn.jsdelivr.net/jquery.cookie/1.4.1/jquery.cookie.min.js
- // @require http://crypto-js.googlecode.com/svn/tags/3.1.2/build/rollups/sha1.js
- // @copyright 2014+, Lej
- // ==/UserScript==
- $(document).ready(function() {
- var page="Unknown";
- if (document.title=="TagPro Capture the Flag")
- page = "Homepage";
- else if (document.title=="TagPro Group")
- page = "In Group";
- else if (document.title=="TagPro")
- page = "In Game";
- else if (document.title.indexOf("TagPro Ball:")>-1)
- page = "Viewing Profile";
- else if (document.title=="Play with Friends")
- page = "Viewing Groups";
- else if (document.title=="Create a new TagPro Group")
- page = "Creating Group";
- else if (document.title=="TagPro Leader Boards")
- page = "Viewing Leaderboard";
- else if (document.title=="Looking for a TagPro Game...")
- page = "Searching for Game";
- else if (document.title=="Support TagPro!")
- page = "Donating";
- if (page == "Homepage") {
- if ($("a[href*='/auth/google']").attr("href") == "/auth/google")
- $.removeCookie('hash');
- else {
- var hash = $("a[href*='profile']").attr("href");
- hash = hash.split("/");
- $.cookie('hash',hash[2],{path:'/'});
- if (typeof $.cookie('token') == "undefined") {
- getToken()
- }
- }
- }
- var token = $.cookie('token');
- hash = $.cookie('hash');
- if (typeof hash == "undefined")
- console.log("I couldn't get your hash! Are you signed in? If so, visit the homepage of your TagPro server so I can grab it real fast...");
- else {
- if ($.cookie('friendsControl') == "hide")
- $("body").append("<div id=\"friends\" style=\"z-index: 100; padding:5px; overflow:hidden; border-bottom:15px solid black; position:fixed; bottom:0px; left:15%; margin-left:-175px; width:350px; height:20px; background-color:rgba(0,0,0,.65);\"> \
- <div id=\"friendsControl\" style=\"cursor:pointer; font-size:1.2em; font-weight:bold; background-color:yellow; font-weight:bold; color:black; position:absolute; top:0px; right:0px;; border:1px solid black;\">↑</div></div>");
- else
- $("body").append("<div id=\"friends\" style=\"z-index: 100; padding:5px; overflow:hidden; border-bottom:15px solid black; position:fixed; bottom:0px; left:15%; margin-left:-175px; width:350px; height:300px; background-color:rgba(0,0,0,.65);\"> \
- <div id=\"friendsControl\" style=\"cursor:pointer; font-size:1.2em; font-weight:bold; background-color:yellow; font-weight:bold; color:black; position:absolute; top:0px; right:0px; border:1px solid black;\">↓</div></div>");
- $("#friends").append("<div style=\"font-size:1.4em;\" id=\"friendsHeader\">Friends</div><div style=\"overflow-y:auto;height:280px;\" id=\"friendsContent\">Loading...</div>");
- var server = document.URL;
- server = server.split("-");
- server=server[1].split(".");
- server=server[0];
- update(hash,token,page,server);
- setInterval(function(){update(hash,token,page,server)},4000);
- $("#friendsControl").click(function() {
- if ($.cookie('friendsControl') == "hide") {
- $.cookie('friendsControl','show',{path:'/'});
- update(hash,token,page);
- $("#friends").animate({height:300});
- $("#friendsControl").html("↓")
- } else {
- $.cookie('friendsControl','hide',{path:'/'});
- $("#friends").animate({height:20});
- $("#friendsControl").html("↑")
- }
- });
- $(window).on('beforeunload',function() {
- $.post("http://lejdesigns.com/tp/functions/friends.php",{page:"Offline",hash:hash,token:token})
- });
- if (page == "Viewing Profile") {
- var urlParts=document.URL.split("/");
- var theirHash=urlParts[4];
- if (hash != theirHash) {
- $.post("http://lejdesigns.com/tp/functions/checkFriend.php",{myHash:hash,token:token,theirHash:theirHash,ref:document.URL},function(data) {
- $("h3").append("<div style=\"margin-top:10px;font-size:.7em;\">"+data+"</div>")})
- }
- }
- }
- });
- function update (hash,token,page,server) {
- if ($.cookie('friendsControl') != "hide") {
- if (tagpro.group)
- var groupLink=document.URL;
- $.post("http://lejdesigns.com/tp/functions/friends.php",{ref:document.URL,server:server,hash:hash,token:token,page:page,groupLink:groupLink},
- function(data) {
- $("#friendsContent").html(data)
- })
- }
- }
- function getToken() {
- var token = prompt("What is your Friends list password? (NOTE: If this is your first time seeing this, please come up with a password for your Friends list.)");
- if (!token)
- getToken();
- else {
- token=CryptoJS.SHA1(token);
- $.cookie('token',token,{expires:365,path:'/'})
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment