Greasy Fork 还支持 简体中文。

Jstris Stats Script

change the color of stats

目前為 2020-04-27 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name Jstris Stats Script
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.2.1
  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. sprintText.style.color = colorhex_linesRemaining
  24. lrem.style.color = colorhex_linesRemaining
  25.  
  26. function hexToRgb(hex) {
  27. var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
  28. return result ? [parseInt(result[1], 16),parseInt(result[2], 16),parseInt(result[3], 16)] : null
  29. }
  30.  
  31. //canvas2d
  32. var trim=a=>{a=a.slice(0,-1);a=a.substr(a.indexOf("{")+1);return a}
  33. var getParams=a=>{var params=a.slice(a.indexOf("(")+1);params=params.substr(0,params.indexOf(")")).split(",");return params}
  34.  
  35. var fastFont = FastFont2D['prototype']['draw'].toString()
  36. var params = getParams(fastFont)
  37. fastFont = trim(fastFont).split("=")
  38. fastFont[2] = fastFont[2].split(";")
  39. fastFont[2][0] = "'"+colorhex_numbers+"'"
  40. fastFont[2] = fastFont[2].join(";")
  41. fastFont = fastFont.join("=")
  42.  
  43. FastFont2D['prototype']['draw'] = new Function(...params, fastFont);
  44.  
  45. rgb = hexToRgb(colorhex_numbers)
  46. oldcolor = "[128/ 255,128/ 255,128/ 255,1]"
  47. newcolor = "["+rgb[0]+"/ 255, "+rgb[1]+" / 255, "+rgb[2]+" / 255, 1]"
  48.  
  49. //webgl
  50. window.resetColor = true;
  51.  
  52. fastFont = FastFont['prototype']['draw'].toString()
  53. params = getParams(fastFont)
  54. fastFont = trim(fastFont).replace(oldcolor,newcolor)
  55. fastFont = "if(resetColor){this['glParamsSet']=false;resetColor=0};" + fastFont
  56.  
  57. FastFont['prototype']['draw'] = new Function(...params, fastFont);
  58.  
  59. //changes the color of the texts
  60. statLabels.style.color = colorhex_text
  61. });
  62. })();