Advertisement
Guest User

Tagpro Tweaks 1.3.1

a guest
Jan 7th, 2015
875
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.26 KB | None | 0 0
  1. // ==UserScript==
  2. // @name Tagpro Tweaks 1.3.1
  3. // @version 1.3.1
  4. // @description Small tweaks for tagpro
  5. // @author Despair
  6. // @include http://*.koalabeast.com:*
  7. // @include http://*.jukejuice.com:*
  8. // @include http://*.newcompte.fr:*
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. // Enable/Disable tweaks
  13. var tkSwitchButton = true,// button to switch teams
  14. tkReservedButton = true,// button to set name to reserved
  15. //tkNarrowViewport = false,// make viewport border 1 px wide - BROKEN -
  16. tkHideAd = false,// hide scoreboard ad
  17. tkOutlineScore = true,// adds an outline to the team scores
  18. tkShowMapName = true,// show map name before game starts
  19. tkHideMouse = true,// hide the mouse when not in use
  20. tkDisableRClick = false;// disables the right click menu
  21.  
  22. // Settings
  23. var reservedName = "NAME HERE",// your reserved name
  24. moveSwitch = false,// move switch teams button lower
  25. switchOpacity = 0.35,// make switch button transparent when mouse not on it
  26. mouseTimeDefault = 3000;// time(ms) after last movement to hide mouse
  27.  
  28. // Variables
  29. var mouseTime = 0,// keeps track of time since mouse moved - counts down
  30. isMouseHidden = false;// if mouse is currently hidden
  31.  
  32. // call functions after startup
  33. tagpro.ready(function(){
  34. replaceStartMsg();
  35. setTimeout(function(){
  36. startup();
  37. },1000);
  38. });
  39.  
  40. function startup(){
  41. tweakSwitchButton();
  42. tweakReservedButton();
  43. //tweakViewPort();
  44. tweakHideAd();
  45. tweakOutlineScore();
  46. tweakRightClick();
  47. mouseTime = mouseTimeDefault;
  48. }
  49.  
  50. //button to switch teams
  51. function tweakSwitchButton(){
  52. if(tkSwitchButton){
  53. var button = document.createElement('button');
  54. button.innerHTML = "Switch Team";
  55. button.onclick=switchTeams;
  56. button.style.opacity=switchOpacity;
  57. button.onmouseover= function(){button.style.cursor="pointer";button.style.opacity=1;};
  58. button.onmouseleave= function(){button.style.opacity=switchOpacity;};
  59. document.getElementById("sound").appendChild(button);
  60. if(moveSwitch){
  61. button.style.position = "absolute";
  62. button.style.right = "0px";
  63. button.style.bottom = "-100px";
  64. }
  65. }
  66. }
  67.  
  68. function switchTeams(){tagpro.socket.emit("switch");}
  69.  
  70. //button to set name as reserved
  71. function tweakReservedButton(){
  72. if(tkReservedButton){
  73. var button = document.createElement('button');
  74. button.innerHTML = "Reserved";
  75. button.onclick=setName;
  76. button.onmouseover= function(){button.style.cursor="pointer";};
  77. document.getElementById("optionsName").appendChild(button);
  78. }
  79. }
  80.  
  81. function setName(){tagpro.socket.emit("name", reservedName.substring(0,12));}
  82.  
  83. /*
  84. // Makes the viewport border smaller
  85. function tweakViewPort(){
  86. if(tkNarrowViewport){document.getElementById('viewPortDiv').style.border = '1px solid white';}
  87. }
  88. */
  89.  
  90. // Hide scoreboard ad
  91. function tweakHideAd(){
  92. if(tkHideAd){
  93. var ad = document.getElementById("optionsAd");
  94. ad.style.position = "absolute"; ad.style.bottom = "-500px";
  95. }
  96. }
  97.  
  98. // Outline scores
  99. function tweakOutlineScore(){
  100. if(tkOutlineScore){
  101. outlineLoop = setInterval(function(){
  102. checkUI();// check if window is in focus
  103. },1000);
  104. }
  105. }
  106.  
  107. function checkUI(){
  108. if(tagpro.ui.sprites.redScore.alpha !== undefined){
  109. clearInterval(outlineLoop);
  110. changeUI();
  111. }
  112. }
  113.  
  114. function changeUI(){
  115. var redScoreCache = tagpro.score.r, blueScoreCache = tagpro.score.b;
  116. var redText = tagpro.ui.sprites.redScore,
  117. blueText = tagpro.ui.sprites.blueScore;
  118. redText.alpha = 1; blueText.alpha = 1;
  119. redText.style.fill = "rgba(255, 0, 0, .5)"; redText.style.strokeThickness = 2;
  120. blueText.style.fill = "rgba(0, 0, 255, .5)"; blueText.style.strokeThickness = 2;
  121. tagpro.score.r = "-"; tagpro.score.b = "-";// force scores to update
  122. setTimeout(function(){
  123. tagpro.score.r = redScoreCache; tagpro.score.b = blueScoreCache;
  124. },1000);
  125. }
  126.  
  127. //get map name
  128. function getMapName(){
  129. var mapInfo = $("#mapInfo").text(), mapName, end;
  130. end = mapInfo.indexOf(" by ");
  131. mapName = mapInfo.substr(5,end-5);
  132. return mapName;
  133. }
  134.  
  135. function replaceStartMsg(){
  136. tagpro.ui.largeAlert = function (e,t,n,r,i){
  137. if(tkShowMapName){
  138. if(r == "Match Begins Soon..."){r = getMapName();}
  139. }
  140. var s=tagpro.renderer.largeText(r,i);
  141. return s.x=Math.round(t.x-s.width/2),s.y=100,e.addChild(s),s;
  142. };
  143. }
  144.  
  145. //hide idle mouse
  146. mouseMoveTimer = setInterval(function(){
  147. mouseHider();
  148. },500);
  149.  
  150. function mouseHider(){
  151. if(tkHideMouse){
  152. mouseTime = mouseTime - 500;
  153. if(mouseTime > 0 && isMouseHidden){
  154. document.body.style.cursor = 'auto';
  155. isMouseHidden = false;
  156. }else if(mouseTime <= 0 && !isMouseHidden){
  157. document.body.style.cursor = 'none';
  158. isMouseHidden = true;
  159. }
  160. }
  161. }
  162.  
  163. window.onmousemove = mouseMoved;
  164. function mouseMoved(){mouseTime = mouseTimeDefault;}
  165.  
  166. function tweakRightClick(){
  167. if(tkDisableRClick){
  168. window.oncontextmenu = function(){return false;};
  169. }
  170. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement