UserNameWTF

Friends Script Moved

Oct 12th, 2014
311
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.39 KB | None | 0 0
  1. // ==UserScript==
  2. // @name Friends
  3. // @version 1
  4. // @description The long awaited Friends script!
  5. // @include http://tagpro-*.koalabeast.com*
  6. // @require //cdn.jsdelivr.net/jquery.cookie/1.4.1/jquery.cookie.min.js
  7. // @require http://crypto-js.googlecode.com/svn/tags/3.1.2/build/rollups/sha1.js
  8. // @copyright 2014+, Lej
  9. // ==/UserScript==
  10. $(document).ready(function() {
  11.  
  12. var page="Unknown";
  13.  
  14. if (document.title=="TagPro Capture the Flag")
  15. page = "Homepage";
  16.  
  17. else if (document.title=="TagPro Group")
  18. page = "In Group";
  19.  
  20. else if (document.title=="TagPro")
  21. page = "In Game";
  22.  
  23. else if (document.title.indexOf("TagPro Ball:")>-1)
  24. page = "Viewing Profile";
  25.  
  26. else if (document.title=="Play with Friends")
  27. page = "Viewing Groups";
  28.  
  29. else if (document.title=="Create a new TagPro Group")
  30. page = "Creating Group";
  31.  
  32. else if (document.title=="TagPro Leader Boards")
  33. page = "Viewing Leaderboard";
  34.  
  35. else if (document.title=="Looking for a TagPro Game...")
  36. page = "Searching for Game";
  37.  
  38. else if (document.title=="Support TagPro!")
  39. page = "Donating";
  40.  
  41. if (page == "Homepage") {
  42. if ($("a[href*='/auth/google']").attr("href") == "/auth/google")
  43. $.removeCookie('hash');
  44.  
  45. else {
  46. var hash = $("a[href*='profile']").attr("href");
  47. hash = hash.split("/");
  48. $.cookie('hash',hash[2],{path:'/'});
  49.  
  50. if (typeof $.cookie('token') == "undefined") {
  51. getToken()
  52. }
  53. }
  54. }
  55.  
  56. var token = $.cookie('token');
  57. hash = $.cookie('hash');
  58.  
  59. if (typeof hash == "undefined")
  60. 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...");
  61.  
  62. else {
  63. if ($.cookie('friendsControl') == "hide")
  64. $("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);\"> \
  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>");
  66.  
  67. else
  68. $("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);\"> \
  69. <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>");
  70. $("#friends").append("<div style=\"font-size:1.4em;\" id=\"friendsHeader\">Friends</div><div style=\"overflow-y:auto;height:280px;\" id=\"friendsContent\">Loading...</div>");
  71.  
  72. var server = document.URL;
  73. server = server.split("-");
  74. server=server[1].split(".");
  75. server=server[0];
  76. update(hash,token,page,server);
  77. setInterval(function(){update(hash,token,page,server)},4000);
  78.  
  79. $("#friendsControl").click(function() {
  80. if ($.cookie('friendsControl') == "hide") {
  81. $.cookie('friendsControl','show',{path:'/'});
  82. update(hash,token,page);
  83. $("#friends").animate({height:300});
  84. $("#friendsControl").html("↓")
  85. } else {
  86. $.cookie('friendsControl','hide',{path:'/'});
  87. $("#friends").animate({height:20});
  88. $("#friendsControl").html("↑")
  89. }
  90. });
  91.  
  92. $(window).on('beforeunload',function() {
  93. $.post("http://lejdesigns.com/tp/functions/friends.php",{page:"Offline",hash:hash,token:token})
  94. });
  95.  
  96. if (page == "Viewing Profile") {
  97. var urlParts=document.URL.split("/");
  98. var theirHash=urlParts[4];
  99. if (hash != theirHash) {
  100. $.post("http://lejdesigns.com/tp/functions/checkFriend.php",{myHash:hash,token:token,theirHash:theirHash,ref:document.URL},function(data) {
  101. $("h3").append("<div style=\"margin-top:10px;font-size:.7em;\">"+data+"</div>")})
  102. }
  103. }
  104. }
  105. });
  106.  
  107. function update (hash,token,page,server) {
  108. if ($.cookie('friendsControl') != "hide") {
  109. if (tagpro.group)
  110. var groupLink=document.URL;
  111. $.post("http://lejdesigns.com/tp/functions/friends.php",{ref:document.URL,server:server,hash:hash,token:token,page:page,groupLink:groupLink},
  112. function(data) {
  113. $("#friendsContent").html(data)
  114. })
  115. }
  116. }
  117.  
  118. function getToken() {
  119. 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.)");
  120.  
  121. if (!token)
  122. getToken();
  123.  
  124. else {
  125. token=CryptoJS.SHA1(token);
  126. $.cookie('token',token,{expires:365,path:'/'})
  127. }
  128. }
Advertisement
Add Comment
Please, Sign In to add comment