shh214

UI Upgrade

Jan 15th, 2016
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.89 KB | None | 0 0
  1. // ==UserScript==
  2. // @name TagPro UI Upgrade
  3. // @include http://*.newcompte.fr*
  4. // @include http://tagpro.gg*
  5. // @include http://tagpro.koalabeast.com*
  6. // @include http://capturetheflag.us*
  7. // @include http://tagpro-*.koalabeast.com*
  8. // @version 1.0
  9. // @description Script that modifies the css of TagPro pages
  10. // @author SuperSans
  11. // ==/UserScript==
  12.  
  13. gray_background = false;
  14. var page = window.location.pathname;
  15. var host = (window.location.host.split("."))[1];
  16. var smallGroup = true;
  17. console.log(page);
  18.  
  19. function pageSelect(){
  20. if (page.includes("groups") && page.length >=16) {
  21. groupCSS();
  22. } else if (page.includes("/maps")){
  23. baseChange();
  24. defaultCSS();
  25. mapsCSS();
  26. } else {
  27. baseChange();
  28. defaultCSS();
  29. }
  30. }
  31.  
  32. function baseChange(){
  33.  
  34. var body = document.getElementsByTagName("body");
  35. for(i=0; i<body.length; i++) {
  36. body[i].style.overflowY = "auto";
  37. }
  38.  
  39. var social_things = document.getElementsByClassName("section lineup");
  40. for(i=0; i<social_things.length; i++) {
  41. social_things[i].style.display= 'none';
  42. }
  43.  
  44. var section_smaller = document.getElementsByClassName("section smaller");
  45. for(i=0; i<section_smaller.length; i++) {
  46. section_smaller[i].style.paddingTop = "25px";
  47. }
  48.  
  49. var weekly_donation = document.getElementsByClassName("hideIfExternal section");
  50. for(i=0; i<weekly_donation.length; i++) {
  51. weekly_donation[i].style.display= 'none';
  52. }
  53.  
  54. var h1 = document.getElementsByTagName("h1");
  55. for(i=0; i<h1.length; i++) {
  56. h1[i].style.marginTop = "100px";
  57. h1[i].style.paddingBottom = "20px";
  58. h1[i].style.background = "transparent url(http://i.imgur.com/O4uUPLD.png) no-repeat top left";
  59. h1[i].style.width = "650px";
  60. h1[i].style.height = "137px";
  61. }
  62.  
  63. var article = document.getElementsByTagName("article");
  64. for(i=0; i<article.length; i++) {
  65. article[i].style.width = "1000px";
  66. }
  67. }
  68.  
  69. function defaultCSS(){
  70.  
  71.  
  72.  
  73. var reddit = document.getElementsByClassName("section tiny bottomPadding");
  74. for(i=0; i<reddit.length; i++) {
  75. reddit[i].style.display = "none";
  76. }
  77.  
  78. var a = document.getElementsByTagName("a");
  79. for(i=0; i<a.length; i++) {
  80. a[i].style.color = "white";
  81. }
  82.  
  83. var playbacklinks = document.getElementsByClassName("playback-link");
  84. for(i=0; i<playbacklinks.length; i++) {
  85. playbacklinks[i].style.color = "#428bca";
  86. }
  87.  
  88. var buttons = document.getElementsByClassName("button");
  89. for(i=0; i<buttons.length; i++) {
  90. buttons[i].style.backgroundColor = '#EF423E';
  91. buttons[i].style.border = "solid 3px #FFFFFF";
  92. buttons[i].style.color = "black";
  93. buttons[i].style.minWidth = "14%";
  94. }
  95.  
  96. tagpro.ready(function() {
  97. if (tagpro.state){ //If we are in game
  98. var mapInfo = document.getElementById("mapInfo");
  99. mapInfo.style.float = "none";
  100. mapInfo.style.marginLeft = "auto";
  101. mapInfo.style.marginRight = "auto";
  102. mapInfo.style.width = "100%";
  103. mapInfo.style.fontSize = "150%";
  104. mapInfo.style.fontWeight = "bold";
  105. mapInfo.style.textAlign = "center";
  106.  
  107. var social_things = document.getElementById("optionsLinks");
  108. social_things.style.display = "none";
  109.  
  110. var name = document.getElementById("optionsName");
  111. name.style.position = "absolute";
  112. name.style.top = "28px";
  113. name.style.width = "96.8%";
  114. name.style.textAlign = "center";
  115.  
  116. var switch_teams = document.getElementById("switchButton");
  117. switch_teams.style.position = "absolute";
  118. switch_teams.style.top = "18px";
  119. switch_teams.style.right = "18px";
  120.  
  121. document.getElementById("name").style.marginLeft = "5px";
  122.  
  123. var options = document.getElementById("options");
  124. options.style.width = "1000px";
  125. options.style.left = "0";
  126. options.style.right = "0";
  127. options.style.top = "0";
  128. options.style.bottom = "0";
  129. options.style.margin = "auto";
  130. options.style.boxShadow = "10px 10px 20px 0px rgba(0,0,0,0.35)";
  131. options.style.backgroundColor = "rgba(50,50,50,0.75)";
  132. options.style.border = "none";
  133.  
  134. setTimeout(function() {
  135. var wrapper = document.getElementsByClassName("tablescroll_wrapper")[0];
  136. if (wrapper){
  137.  
  138. var table = document.querySelectorAll("div#options > div + div")[1];
  139. table.style.marginTop = "55px";
  140. table.style.fontSize = "16px";
  141.  
  142. wrapper.style.fontFamily = "Monospace";
  143.  
  144.  
  145. } else {
  146. var table_original = document.getElementById("stats");
  147. table_original.style.marginTop = "55px";
  148. table_original.style.fontSize = "16px";
  149. table_original.style.marginBottom = "25px";
  150. document.getElementsByClassName("stats")[0].style.fontFamily = "Monospace";
  151. }
  152. }, (2 * 1000));
  153.  
  154. }
  155. });
  156. }
  157.  
  158. function groupCSS(){
  159.  
  160. var h1 = document.getElementsByTagName("h1");
  161. for(i=0; i<h1.length; i++) {
  162. h1[i].style.top = "20px";
  163. h1[i].style.background = "transparent url(http://i.imgur.com/ehbQ2xv.png) no-repeat top left";
  164. h1[i].style.width = "166px";
  165. h1[i].style.height = "35px";
  166. }
  167.  
  168. var a = document.getElementsByTagName("a");
  169. for(i=0; i<a.length; i++) {
  170. a[i].style.color = "white";
  171. }
  172.  
  173. document.getElementById("settings").style.top = "70px";
  174.  
  175. var red_box = document.getElementById("redTeam");
  176. red_box.style.width = "38%";
  177. red_box.style.marginRight = "18px";
  178. red_box.style.border = "1px solid rgba(255,255,255,0.20)";
  179. red_box.style.backgroundColor = "rgba(239, 66, 62, 0.5)";
  180.  
  181. var blue_box = document.getElementById("blueTeam");
  182. blue_box.style.width = "38%";
  183. blue_box.style.border = "1px solid rgba(255,255,255,0.20)";
  184. blue_box.style.backgroundColor = "rgba(79, 175, 255, 0.5)";
  185.  
  186. var spectators = document.getElementById("spectators");
  187. spectators.style.width = "21.6%";
  188. spectators.style.marginLeft = "79.3%";
  189. spectators.style.marginTop = "-302px";
  190. spectators.style.border = "1px solid rgba(255,255,255,0.20)";
  191.  
  192. var waiting = document.getElementById("waiting");
  193. waiting.style.width = "21.6%";
  194. waiting.style.marginLeft = "79.3%";
  195. waiting.style.marginTop = "18px";
  196. waiting.style.border = "1px solid rgba(255,255,255,0.20)";
  197. waiting.style.height = "452px!important"; //TODO: This doesn't work
  198.  
  199. var label = document.getElementsByTagName("label");
  200. for(i=0; i<label.length; i++) {
  201. label[i].style.paddingRight = "5px";
  202. }
  203.  
  204. var players = document.getElementsByClassName("ui-sortable");
  205. for(i=0; i<players.length; i++) {
  206. players[i].style.fontWeight = "bold";
  207. }
  208.  
  209. var leader_you = document.getElementsByClassName("leader.you");
  210. for(i=0; i<leader_you.length; i++) {
  211. leader_you[i].style.color = "white";
  212. }
  213.  
  214. var setting_value = document.getElementsByClassName("setting value");
  215. for(i=0; i<setting_value.length; i++) {
  216. setting_value[i].style.paddingTop = "2px";
  217. setting_value[i].style.paddingBottom = "2px";
  218. setting_value[i].style.border = "1px solid rgba(255,255,255,1)";
  219. setting_value[i].style.marginBottom = "2px";
  220. setting_value[i].style.fontFamily = "monospace";
  221. }
  222.  
  223. var button = document.querySelectorAll("button");
  224. for(i=0; i<button.length; i++) {
  225. button[i].style.backgroundColor = '#EF423E';
  226. button[i].style.border = "2px white solid";
  227. }
  228.  
  229. var listener = setInterval(checkPlayerCount, 250);
  230.  
  231.  
  232. }
  233.  
  234. function mapsCSS(){
  235.  
  236. var like = document.getElementsByClassName("like");
  237. for(i=0; i<like.length; i++) {
  238. like[i].style.backgroundColor = "#30ABD6";
  239. }
  240.  
  241. var indifferent = document.getElementsByClassName("indifferent");
  242. for(i=0; i<indifferent.length; i++) {
  243. indifferent[i].style.backgroundColor = "#BBBB17";
  244. }
  245.  
  246. var dislike = document.getElementsByClassName("dislike");
  247. for(i=0; i<dislike.length; i++) {
  248. dislike[i].style.backgroundColor = "#EF423E";
  249. }
  250. }
  251.  
  252. function checkPlayerCount(){
  253.  
  254. var status = document.getElementById("status").innerHTML;
  255. status = status.split(" - ");
  256. var player_count = 0;
  257. for (i=0; i<status.length; i++) {
  258. player_count += parseInt((status[i].split("/"))[0]);
  259. }
  260. if (host == "newcompte" || player_count > 4){
  261. if (smallGroup){
  262. smallGroup = false;
  263. var team_boxes = document.getElementsByClassName("teams");
  264. for(i=0; i<team_boxes.length; i++) {
  265. team_boxes[i].style.left = "370px";
  266. }
  267. document.getElementById("chat").style.right = "19.75%";
  268. }
  269. } else if (!smallGroup){
  270. smallGroup = true;
  271. var team_boxes = document.getElementsByClassName("teams");
  272. for(i=0; i<team_boxes.length; i++) {
  273. team_boxes[i].style.left = "40px";
  274. }
  275. document.getElementById("chat").style.right = "40px";
  276. }
  277.  
  278.  
  279. }
  280.  
  281. if (gray_background){
  282. var html = document.getElementsByTagName("html");
  283. for(i=0; i<html.length; i++) {
  284. html[i].style.background = "#1f1f1f";
  285. }
  286. }
  287. document.onDomContentLoaded = pageSelect();
Add Comment
Please, Sign In to add comment