Advertisement
Guest User

Tagpro Tweaks 1.2

a guest
Nov 16th, 2014
1,859
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.02 KB | None | 0 0
  1. // ==UserScript==
  2. // @name Tagpro Tweaks
  3. // @version 1.2
  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. var tkSwitchButton = true,// button to switch teams
  13. tkReservedButton = true,// button to set name to reserved
  14. tkNarrowViewport = true,// make viewport border 1 px wide
  15. tkHideDonate = true,// hide the donation button
  16. tkOutlineScore = true,// adds an outline to the team scores
  17. tkShowMapName = true,// show map name before game starts
  18. tkHideMouse = true,// hide the mouse when not in use
  19. tkGoSoundJoin = true;// play go sound when you join a game in progress
  20.  
  21. var reservedName = "NAME HERE",// your reserved name
  22. mouseTimeDefault = 2500,// time(ms) after last movement to hide mouse
  23. hideButtonOnLeave = true,// hide switch button when mouse not on it
  24. mouseTime = 0;// keeps track of time since mouse moved - counts down
  25.  
  26. // call functions after startup
  27. setTimeout(function(){
  28. startup()
  29. },1000);
  30.  
  31. function startup(){
  32. tweakSwitchButton()
  33. tweakReservedButton()
  34. tweakViewPort()
  35. tweakHideDonate()
  36. tweakOutlineScore()
  37. tweakGoSound()
  38. mouseTime = mouseTimeDefault
  39. }
  40.  
  41. //button to switch teams
  42. function tweakSwitchButton(){
  43. if(tkSwitchButton){
  44. var button = document.createElement('button');
  45. button.value = "Switch Teams";
  46. button.innerHTML = "Switch Teams";
  47. button.onclick=switchTeams;
  48. if(hideButtonOnLeave){button.style.opacity=0}
  49. button.onmouseover= function(){button.style.cursor="pointer",button.style.opacity=1;}
  50. button.onmouseleave= function(){if(hideButtonOnLeave){button.style.opacity=0;}}
  51. document.getElementById("sound").appendChild(button);
  52. }
  53. }
  54.  
  55. function switchTeams(){tagpro.socket.emit("switch")}
  56.  
  57. //button to set name as reserved
  58. function tweakReservedButton(){
  59. if(tkReservedButton){
  60. var button = document.createElement('button');
  61. button.value = "Reserved Name";
  62. button.innerHTML = "Reserved Name";
  63. button.onclick=setName;
  64. button.onmouseover= function(){button.style.cursor="pointer";}
  65. document.getElementById("optionsName").appendChild(button);
  66. }
  67. }
  68.  
  69. function setName(){tagpro.socket.emit("name", reservedName.substring(0,12));}
  70.  
  71. // Makes the viewport border smaller
  72. function tweakViewPort(){
  73. if(tkNarrowViewport){document.getElementById('viewPortDiv').style.border = '1px solid white'}
  74. }
  75.  
  76. // Hide the donation button
  77. function tweakHideDonate(){
  78. if(tkHideDonate){document.getElementById("donate").style.bottom = "-100px"}
  79. }
  80.  
  81. // Outline scores
  82. function tweakOutlineScore(){
  83. if(tkOutlineScore){
  84. tagpro.ui.scores = function(e,t,n){
  85. var r="",i="";
  86. e.save(),e.textAlign="right",e.fillStyle="rgba(255, 0, 0, .5)",e.strokeStyle="black",e.lineWidth=2,e.font="bold 40pt Arial";
  87. if(tagpro.settings.ui.teamNames==="always"||tagpro.settings.ui.teamNames==="spectating"&&tagpro.spectator)tagpro.teamNames.redTeamName!=="Red"&&(r=tagpro.teamNames.redTeamName+" - "),tagpro.teamNames.blueTeamName!=="Blue"&&(i=" - "+tagpro.teamNames.blueTeamName);
  88. e.strokeText(r+tagpro.score.r,t.x-80,n.height-50),e.fillText(r+tagpro.score.r,t.x-80,n.height-50),e.lineWidth=2,e.textAlign="left",e.fillStyle="rgba(0, 0, 255, .5)",e.strokeText(tagpro.score.b+i,t.x+80,n.height-50),e.fillText(tagpro.score.b+i,t.x+80,n.height-50),e.restore()
  89. }
  90. }
  91. }
  92.  
  93. //get map name
  94. setTimeout(function(){
  95. mapInfo = $("#mapInfo").text()
  96. end = mapInfo.indexOf(" by ")
  97. mapName = mapInfo.substr(5,end-5)
  98. },900)
  99.  
  100. //hide 'game starting soon...' alert so that you can see the map
  101. setTimeout(function(){
  102. tagpro.ui.largeAlert = function (e,t,n,r,i){
  103. if (r == "Match Begins Soon..."){
  104. if(tkShowMapName){r=mapName}
  105. else{r=""}
  106. }
  107. e.save(),e.textAlign="center",e.lineWidth=2,e.font="bold 48pt Arial",e.fillStyle=i||"#ffffff",e.strokeStyle="#000000",e.fillText(r,t.x,100),e.strokeText(r,t.x,100),e.restore
  108. }
  109. },1000)
  110.  
  111. //hide idle mouse
  112. mouseMoveTimer = setInterval(function(){
  113. mouseHider();
  114. },100);
  115.  
  116. var isMouseHidden = false;// if mouse is currently hidden
  117. function mouseHider(){
  118. if(tkHideMouse){
  119. mouseTime = mouseTime - 100
  120. if(mouseTime > 0 && isMouseHidden){
  121. document.body.style.cursor = 'auto';
  122. isMouseHidden = false
  123. }else if(mouseTime < 0 && !isMouseHidden){
  124. document.body.style.cursor = 'none';
  125. isMouseHidden = true
  126. }
  127. }
  128. }
  129.  
  130. window.onmousemove = mouseMoved;
  131. function mouseMoved(){
  132. mouseTime = mouseTimeDefault
  133. }
  134.  
  135. //play go sound
  136. var goSound = new Audio("http://tagpro-origin.koalabeast.com/sounds/go.mp3");
  137. function tweakGoSound(){
  138. if(tkGoSoundJoin && tagpro.state == 1 && !tagpro.spectator){goSound.play()}
  139. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement