Custom Border

Custom map border for agma.io!

目前为 2021-10-14 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name Custom Border
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.2.1
  5. // @description Custom map border for agma.io!
  6. // @author firebone
  7. // @match https://agma.io/
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. // If rainbowMode is false the color will be static at borderColor.
  12.  
  13. var rainbowMode = true;
  14. var borderColor = '#FFFFFF';
  15.  
  16. // --- --- --- --- --- --- ---
  17.  
  18. (function() {
  19. var speed = 5;
  20. function hslToHex(h, s, l) {
  21. h /= 360;
  22. s /= 100;
  23. l /= 100;
  24. let r, g, b;
  25. if (s === 0) {
  26. r = g = b = l;
  27. } else {
  28. const hue2rgb = (p, q, t) => {
  29. if (t < 0) t += 1;
  30. if (t > 1) t -= 1;
  31. if (t < 1 / 6) return p + (q - p) * 6 * t;
  32. if (t < 1 / 2) return q;
  33. if (t < 2 / 3) return p + (q - p) * (2 / 3 - t) * 6;
  34. return p;
  35. };
  36. const q = l < 0.5 ? l * (1 + s) : l + s - l * s;
  37. const p = 2 * l - q;
  38. r = hue2rgb(p, q, h + 1 / 3);
  39. g = hue2rgb(p, q, h);
  40. b = hue2rgb(p, q, h - 1 / 3);
  41. }
  42. const toHex = x => {
  43. const hex = Math.round(x * 255).toString(16);
  44. return hex.length === 1 ? '0' + hex : hex;
  45. };
  46. return `#${toHex(r)}${toHex(g)}${toHex(b)}`;
  47. }
  48.  
  49. var stroke = CanvasRenderingContext2D.prototype.stroke;
  50. CanvasRenderingContext2D.prototype.stroke = function(){
  51. if(this.lineWidth < 10 || this.strokeStyle == "#ffffff" || this.strokeStyle == "#333333" || this.strokeStyle == "#7f7f7f" || this.strokeStyle.slice(5,7) != this.strokeStyle.slice(3,5)) return stroke.apply(this, arguments);
  52. this.strokeStyle = rainbowMode ? hslToHex(Math.floor(Date.now() / speed) % 360, 100, 50) : borderColor;
  53. return stroke.apply(this, arguments);
  54. }
  55. })();