Arbybear

TagPro Leaderboard Countdown

Jul 15th, 2015
274
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.85 KB | None | 0 0
  1. // ==UserScript==
  2. // @name TagPro Leaderboard Countdown
  3. // @namespace http://www.reddit.com/user/Satrex/
  4. // @description Shows a Countdown on the leaderboard until the reset
  5. // @include http://tagpro-*.koalabeast.com/boards
  6. // @include http://tangent.jukejuice.com/boards
  7. // @include http://maptest.newcompte.fr/boards
  8. // @copyright 2014+ Satrex
  9. // @author Satrex
  10. // @version 1.0
  11. // ==/UserScript==
  12. var canvas = document.createElement('canvas');
  13. canvas.id = "CursorLayer";
  14. canvas.width = 213;
  15. canvas.height = 25;
  16. canvas.style.position = "absolute";
  17. canvas.style.border = "1px solid";
  18. canvas.style.display = "inline";
  19. canvas.style.backgroundColor = 'rgba(0,0,0,1)';
  20. canvas.style.marginTop = "255px"
  21. canvas.style.marginLeft = window.innerWidth +"px";
  22.  
  23. var body = document.getElementsByTagName("body")[0];
  24. body.insertBefore(canvas, body.firstChild);
  25.  
  26. cursorLayer = document.getElementById("CursorLayer");
  27. var ctx = cursorLayer.getContext("2d");
  28.  
  29. function daysInMonth(month,year) {
  30. return new Date(year, month, 0).getDate();
  31. }
  32.  
  33. function daily()
  34. {
  35. var dayboard = document.getElementById("Day");
  36. if(dayboard.style.display != "none")
  37. {
  38. cursorLayer.width = 213;
  39. var offset = -7;
  40. var countdowntime = new Date( new Date().getTime() + offset * 3600 * 1000).toUTCString().replace( / GMT$/, "" );
  41.  
  42. var day = countdowntime.substr(5, 2);
  43. var month = countdowntime.substr(8, 3);
  44. var year = countdowntime.substr(12, 4);
  45. var pst = countdowntime.substr(17, 8);
  46.  
  47. var sTimePST = (parseInt(pst.substr(6,7))) + (parseInt(pst.substr(3,4))*60) + (parseInt(pst.substr(0,1))*60*60);
  48.  
  49. var dsLeft = 59 - parseInt(pst.substr(6,2));
  50. var dmLeft = 59 - parseInt(pst.substr(3,2));
  51. var dhLeft = 19 - parseInt(pst.substr(0,2));
  52.  
  53. if (dhLeft< 0)
  54. {
  55. dhLeft = 24 + dhLeft;
  56. }
  57.  
  58. var s10 = "";
  59. var m10 = "";
  60. var h10 = "";
  61.  
  62. if (dsLeft < 10)
  63. {
  64. s10 = "0";
  65.  
  66. }
  67. if (dmLeft <10)
  68. {
  69. m10 = "0";
  70.  
  71. }
  72. if (dhLeft <10)
  73. {
  74. h10 = "0";
  75.  
  76. }
  77. var actualtimer = h10 + (dhLeft).toString() + ":"+ m10 + (dmLeft).toString() + ":" + s10 + (dsLeft).toString();
  78.  
  79. actualtimer = "Time until reset: " + actualtimer;
  80. ctx.fillStyle="#FFFFFF";
  81. ctx.font="20px Hallo Sans Light";
  82. ctx.clearRect(0, 0, canvas.width, canvas.height);
  83.  
  84. ctx.fillText(actualtimer,1,20);
  85. }
  86.  
  87.  
  88. }
  89. setInterval(daily,1000);
  90.  
  91. function weekly()
  92. {
  93. var weekboard = document.getElementById("Week");
  94. if(weekboard.style.display != "none")
  95. {
  96. cursorLayer.width = 230;
  97. var offset = -7;
  98. var wcountdowntime = new Date( new Date().getTime() + offset * 3600 * 1000).toUTCString().replace( / GMT$/, "" );
  99.  
  100. var weekday = wcountdowntime.substr(0, 3);
  101. var wday = wcountdowntime.substr(5, 2);
  102. var wmonth = wcountdowntime.substr(8, 3);
  103. var wyear = wcountdowntime.substr(12, 4);
  104. var wpst = wcountdowntime.substr(17, 8);
  105.  
  106. var sTimePST = (parseInt(wpst.substr(6,7))) + (parseInt(wpst.substr(3,4))*60) + (parseInt(wpst.substr(0,1))*60*60);
  107.  
  108.  
  109. var days = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
  110. weekday = days.indexOf(weekday);
  111. weekday = 7 - weekday;
  112.  
  113. var wdsLeft = 59 - parseInt(wpst.substr(6,2));
  114. var wdmLeft = 59 - parseInt(wpst.substr(3,2));
  115. var wdhLeft = 19 - parseInt(wpst.substr(0,2));
  116.  
  117. if(wdhLeft<0)
  118. {
  119. wdhLeft = 24 + wdhLeft;
  120. }
  121.  
  122. var ws10 = "";
  123. var wm10 = "";
  124. var wh10 = "";
  125.  
  126. if (wdsLeft < 10)
  127. {
  128. ws10 = "0";
  129.  
  130. }
  131. if (wdmLeft < 10)
  132. {
  133. wm10 = "0";
  134.  
  135. }
  136. if (wdhLeft < 10)
  137. {
  138. wh10 = "0";
  139.  
  140. }
  141. var weeklytimer = weekday.toString() + ":" + wh10 + (wdhLeft).toString() + ":" + wm10 + (wdmLeft).toString() + ":" + ws10 + (wdsLeft).toString();
  142. weeklytimer = "Time until reset: " + weeklytimer;
  143. ctx.fillStyle="#FFFFFF";
  144. ctx.font="20px Hallo Sans Light";
  145. ctx.clearRect(0, 0, canvas.width, canvas.height);
  146.  
  147. ctx.fillText(weeklytimer,1,20);
  148. }
  149.  
  150.  
  151. }
  152. setInterval(weekly,1000);
  153.  
  154.  
  155.  
  156.  
  157. function monthly()
  158. {
  159. var monthboard = document.getElementById("Month");
  160. if(monthboard.style.display != "none")
  161. {
  162. var offset = -7;
  163. var countdowntime = new Date( new Date().getTime() + offset * 3600 * 1000).toUTCString().replace( / GMT$/, "" );
  164.  
  165. var day = parseInt(countdowntime.substr(5, 2));
  166. var month = countdowntime.substr(8, 3);
  167. var year = parseInt(countdowntime.substr(12, 4));
  168. var pst = countdowntime.substr(17, 8);
  169.  
  170. var sTimePST = (parseInt(pst.substr(6,7))) + (parseInt(pst.substr(3,4))*60) + (parseInt(pst.substr(0,1))*60*60);
  171.  
  172. var dsLeft = 59 - parseInt(pst.substr(6,2));
  173. var dmLeft = 59 - parseInt(pst.substr(3,2));
  174. var dhLeft = 19 - parseInt(pst.substr(0,2));
  175.  
  176. if (dhLeft< 0)
  177. {
  178. dhLeft = 24 + dhLeft;
  179. }
  180.  
  181. var s10 = "";
  182. var m10 = "";
  183. var h10 = "";
  184.  
  185. if (dsLeft < 10)
  186. {
  187. s10 = "0";
  188.  
  189. }
  190. if (dmLeft <10)
  191. {
  192. m10 = "0";
  193.  
  194. }
  195. if (dhLeft <10)
  196. {
  197. h10 = "0";
  198.  
  199. }
  200. var actualtimer = h10 + (dhLeft).toString() + ":"+ m10 + (dmLeft).toString() + ":" + s10 + (dsLeft).toString();
  201.  
  202. var month = (new Date( new Date().getTime() + offset * 3600 * 1000)).getMonth() + 1;
  203.  
  204. var ndays = daysInMonth(month,year);
  205.  
  206. day = ndays - day + 1;
  207. if (day == 1)
  208. {
  209. day = 0;
  210. }
  211.  
  212. if( day > 9)
  213. {
  214. cursorLayer.width = 240;
  215. }
  216. if( day < 10)
  217. {
  218. cursorLayer.width = 230;
  219. }
  220.  
  221. actualtimer = "Time until reset: " + day.toString() +":" + actualtimer;
  222. ctx.fillStyle="#FFFFFF";
  223. ctx.font="20px Hallo Sans Light";
  224. ctx.clearRect(0, 0, canvas.width, canvas.height);
  225.  
  226. ctx.fillText(actualtimer,1,20);
  227. }
  228.  
  229.  
  230. }
  231. setInterval(monthly,1000);
  232.  
  233. function center()
  234. {
  235. cursorLayer.style.marginLeft = Math.round((window.innerWidth / 2) - (cursorLayer.width /2)) +"px";
  236. }
  237. setInterval(center,30);
Add Comment
Please, Sign In to add comment