Greasy Fork is available in English.

Chess.com Game Preview Styling

Applies custom styling to Chess.com board components.

  1. // ==UserScript==
  2. // @name Chess.com Game Preview Styling
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.6
  5. // @description Applies custom styling to Chess.com board components.
  6. // @author SaberSpeed77
  7. // @match https://www.chess.com/*
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=chess.com
  9. // @grant none
  10. // @license MIT
  11. // ==/UserScript==
  12. const imgs = new Map([
  13. /* White Pieces */
  14. ["wp", ""],
  15. ["wn", ""],
  16. ["wb", ""],
  17. ["wr", ""],
  18. ["wq", ""],
  19. ["wk", ""],
  20.  
  21. /* Black Pieces */
  22. ["bp", ""],
  23. ["bn", ""],
  24. ["bb", ""],
  25. ["br", ""],
  26. ["bq", ""],
  27. ["bk", ""],
  28. ]);
  29.  
  30. /* Background */
  31. const background = "";
  32.  
  33. /*========= ↑ STYLE / CODE ↓ =========*/
  34.  
  35. const styleElement = document.createElement("style");
  36. const CSS = `
  37. *:not(svg) {
  38. --theme-piece-set-wp: url(${imgs.get("wp")});
  39. --theme-piece-set-wn: url(${imgs.get("wn")});
  40. --theme-piece-set-wb: url(${imgs.get("wb")});
  41. --theme-piece-set-wr: url(${imgs.get("wr")});
  42. --theme-piece-set-wq: url(${imgs.get("wq")});
  43. --theme-piece-set-wk: url(${imgs.get("wk")});
  44.  
  45. --theme-piece-set-bp: url(${imgs.get("bp")});
  46. --theme-piece-set-bn: url(${imgs.get("bn")});
  47. --theme-piece-set-bb: url(${imgs.get("bb")});
  48. --theme-piece-set-br: url(${imgs.get("br")});
  49. --theme-piece-set-bq: url(${imgs.get("bq")});
  50. --theme-piece-set-bk: url(${imgs.get("bk")});
  51.  
  52. --theme-board-style-image: url(${background});
  53. }
  54. `
  55.  
  56. styleElement.appendChild(document.createTextNode(CSS));
  57. document.head.appendChild(styleElement);