Jstris Stats Script

change the color of stats

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください。
  1. // ==UserScript==
  2. // @name Jstris Stats Script
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.2.2
  5. // @description change the color of stats
  6. // @author jezevec10
  7. // @match https://*.jstris.jezevec10.com/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. /**************************
  12. Jstris Stats Script
  13. **************************/
  14.  
  15. (function() {
  16. window.addEventListener('load', function(){
  17.  
  18. //default color is #808080 for both
  19. colorhex_numbers = "#FFB600"
  20. colorhex_text = "#B6FFAA"
  21. colorhex_linesRemaining = "#C0FFEE"
  22.  
  23. colorhex_replay = "#FF0000"
  24.  
  25. if(typeof Game == "undefined"){
  26. document.querySelectorAll("[id='stats']").forEach((stat) => {
  27. stat.style.color = colorhex_replay
  28. })
  29. }
  30.  
  31. sprintText.style.color = colorhex_linesRemaining
  32. lrem.style.color = colorhex_linesRemaining
  33.  
  34. function hexToRgb(hex) {
  35. var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
  36. return result ? [parseInt(result[1], 16),parseInt(result[2], 16),parseInt(result[3], 16)] : null
  37. }
  38.  
  39. //canvas2d
  40. var trim=a=>{a=a.slice(0,-1);a=a.substr(a.indexOf("{")+1);return a}
  41. var getParams=a=>{var params=a.slice(a.indexOf("(")+1);params=params.substr(0,params.indexOf(")")).split(",");return params}
  42.  
  43. var fastFont = FastFont2D['prototype']['draw'].toString()
  44. var params = getParams(fastFont)
  45. fastFont = trim(fastFont).split("=")
  46. fastFont[2] = fastFont[2].split(";")
  47. fastFont[2][0] = "'"+colorhex_numbers+"'"
  48. fastFont[2] = fastFont[2].join(";")
  49. fastFont = fastFont.join("=")
  50.  
  51. FastFont2D['prototype']['draw'] = new Function(...params, fastFont);
  52.  
  53. rgb = hexToRgb(colorhex_numbers)
  54. oldcolor = "[128/ 255,128/ 255,128/ 255,1]"
  55. newcolor = "["+rgb[0]+"/ 255, "+rgb[1]+" / 255, "+rgb[2]+" / 255, 1]"
  56.  
  57. //webgl
  58. window.resetColor = true;
  59.  
  60. fastFont = FastFont['prototype']['draw'].toString()
  61. params = getParams(fastFont)
  62. fastFont = trim(fastFont).replace(oldcolor,newcolor)
  63. fastFont = "if(resetColor){this['glParamsSet']=false;resetColor=0};" + fastFont
  64.  
  65. FastFont['prototype']['draw'] = new Function(...params, fastFont);
  66.  
  67. //changes the color of the texts
  68. statLabels.style.color = colorhex_text
  69. });
  70. })();