Guest User

Tagpro Tweaks 1.1

a guest
Oct 24th, 2014
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.28 KB | None | 0 0
  1. // ==UserScript==
  2. // @name Tagpro Tweaks
  3. // @version 1.1
  4. // @description Small tweaks for tagpro
  5. // @author Despair
  6. // @include http://tagpro-*.koalabeast.com:*
  7. // @include http://tangent.jukejuice.com:*
  8. // @include http://*.newcompte.fr:*
  9. // ==/UserScript==
  10.  
  11. var tkSwitchButton = true,// button to switch teams
  12. tkNarrowViewport = true,// make viewport border 1 px wide
  13. tkHideDonate = true,// hide the donation button
  14. tkOutlineScore = true,// adds an outline to the team scores
  15. tkShowMapName = true,// show map name before game starts
  16. tkHideMouse = true,// hide the mouse when not in use
  17. tkGoSoundJoin = true;// play go sound when you join a game in progress
  18.  
  19. var mouseTimeDefault = 2500,// time(ms) after last movement to hide mouse
  20. hideButtonOnLeave = true;// hide switch button when mouse not on it
  21.  
  22. // call functions after startup
  23. setTimeout(function(){
  24. startup()
  25. },1000);
  26.  
  27. function startup(){
  28. tweakSwitchButton()
  29. tweakViewPort()
  30. tweakHideDonate()
  31. tweakOutlineScore()
  32. tweakGoSound()
  33. mouseTime = mouseTimeDefault
  34. }
  35.  
  36. //button to switch teams
  37. function tweakSwitchButton(){
  38. if(tkSwitchButton){
  39. var button = document.createElement('button');
  40. button.value = "Switch Teams";
  41. button.innerHTML = "Switch Teams";
  42. button.onclick=switchTeams;
  43. if(hideButtonOnLeave){button.style.opacity=0}
  44. button.onmouseover= function(){button.style.cursor="pointer",button.style.opacity=1;}
  45. button.onmouseleave= function(){if(hideButtonOnLeave){button.style.opacity=0;}}
  46. document.getElementById("sound").appendChild(button);
  47. }
  48. }
  49.  
  50. function switchTeams(){tagpro.socket.emit("switch")}
  51.  
  52. // Makes the viewport border smaller
  53. function tweakViewPort(){
  54. if(tkNarrowViewport){document.getElementById('viewPortDiv').style.border = '1px solid white'}
  55. }
  56.  
  57. // Hide the donation button
  58. function tweakHideDonate(){
  59. if(tkHideDonate){document.getElementById("donate").style.bottom = "-100px"}
  60. }
  61.  
  62. // Outline scores
  63. function tweakOutlineScore(){
  64. if(tkOutlineScore){
  65. tagpro.ui.scores = function(e,t,n){
  66. var r="",i="";
  67. e.save(),e.textAlign="right",e.fillStyle="rgba(255, 0, 0, .5)",e.strokeStyle="black",e.lineWidth=2,e.font="bold 40pt Arial";
  68. 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);
  69. 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()
  70. }
  71. }
  72. }
  73.  
  74. //get map name
  75. setTimeout(function(){
  76. mapInfo = $("#mapInfo").text()
  77. end = mapInfo.indexOf(" by ")
  78. mapName = mapInfo.substr(5,end-5)
  79. },900)
  80.  
  81. //hide 'game starting soon...' alert so that you can see the map
  82. setTimeout(function(){
  83. tagpro.ui.largeAlert = function (e,t,n,r,i){
  84. if (r == "Match Begins Soon..."){
  85. if(tkShowMapName){r=mapName}
  86. else{r=""}
  87. }
  88. 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
  89. }
  90. },1000)
  91.  
  92. //hide idle mouse
  93. mouseMoveTimer = setInterval(function(){
  94. mouseHider();
  95. },100);
  96.  
  97. var isMouseHidden = false;// if mouse is currently hidden
  98. function mouseHider(){
  99. if(tkHideMouse){
  100. mouseTime = mouseTime - 100
  101. if(mouseTime > 0 && isMouseHidden){
  102. document.body.style.cursor = 'auto';
  103. isMouseHidden = false
  104. }else if(mouseTime < 0 && !isMouseHidden){
  105. document.body.style.cursor = 'none';
  106. isMouseHidden = true
  107. }
  108. }
  109. }
  110.  
  111. window.onmousemove = mouseMoved;
  112. function mouseMoved(){
  113. mouseTime = mouseTimeDefault
  114. }
  115.  
  116. //play go sound
  117. var goSound = new Audio("http://tagpro-origin.koalabeast.com/sounds/go.mp3");
  118. function tweakGoSound(){
  119. if(tkGoSoundJoin && tagpro.state == 1){goSound.play()}
  120. }
Advertisement
Add Comment
Please, Sign In to add comment