Chess.com Custom Pieces

A simple JavaScript project where it changes the pieces of chess.com with anything you want!

  1. // ==UserScript==
  2. // @name Chess.com Custom Pieces
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.5
  5. // @description A simple JavaScript project where it changes the pieces of chess.com with anything you want!
  6. // @author SkidFace
  7. // @match https://www.chess.com/*
  8. // @icon https://www.dictionary.com/e/wp-content/uploads/2020/02/uwu_800x800-300x300.jpg
  9. // @license MIT
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13. //IMPORTANT!!!
  14.  
  15. //To use and modify this script to replace the images, simply replace the inside of the "url()" component of that const with a link to the image
  16. //For example, if I wanted to change the White King piece to an UwU face, you would change line 34 to:
  17.  
  18. //const whiteKing = "url(https://avaazdo.s3.amazonaws.com/original_5ccdb9b8604f2.jpg)"
  19.  
  20.  
  21. const blackPawn = "url()";
  22. const blackRook = "url()";
  23. const blackKnight = "url()";
  24. const blackBishop = "url()";
  25. const blackQueen = "url()";
  26. const blackKing = "url()";
  27.  
  28.  
  29. const whitePawn = "url()";
  30. const whiteRook = "url()";
  31. const whiteKnight = "url()";
  32. const whiteBishop = "url()";
  33. const whiteQueen = "url()";
  34. const whiteKing = "url()";
  35.  
  36. //You do not need to change anything below. All you need to do is change the code above.
  37.  
  38.  
  39. window.addEventListener('load', function() {
  40. //black pieces
  41. changePiece("bp", blackPawn);
  42. changePiece("br", blackRook);
  43. changePiece("bn", blackKnight);
  44. changePiece("bb", blackBishop);
  45. changePiece("bq", blackQueen);
  46. changePiece("bk", blackKing);
  47.  
  48. //white pieces
  49. changePiece("wp", whitePawn);
  50. changePiece("wr", whiteRook);
  51. changePiece("wn", whiteKnight);
  52. changePiece("wb", whiteBishop);
  53. changePiece("wq", whiteQueen);
  54. changePiece("wk", whiteKing);
  55. });
  56.  
  57. function changePiece(piece, url){
  58. for (let i = 0; i < document.getElementsByClassName(piece).length; i++) {
  59. document.getElementsByClassName(piece)[i].style.backgroundImage = url;
  60. }
  61. }