Chess.com Custom Pieces

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

当前为 2022-03-21 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Chess.com Custom Pieces
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.3
  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.  
  37. //You do not need to change anything below. All you need to do is change the code above.
  38.  
  39. (function() {
  40.  
  41. 'use strict';
  42. setTimeout(function(){
  43. //black pieces
  44. changePiece("bp", blackPawn);
  45. changePiece("br", blackRook);
  46. changePiece("bn", blackKnight);
  47. changePiece("bb", blackBishop);
  48. changePiece("bq", blackQueen);
  49. changePiece("bk", blackKing);
  50.  
  51. //white pieces
  52. changePiece("wp", whitePawn);
  53. changePiece("wr", whiteRook);
  54. changePiece("wn", whiteKnight);
  55. changePiece("wb", whiteBishop);
  56. changePiece("wq", whiteQueen);
  57. changePiece("wk", whiteKing);
  58.  
  59. }, 100);
  60. })();
  61.  
  62. function changePiece(piece, url){
  63. for (let i = 0; i < document.getElementsByClassName(piece).length; i++) {
  64. document.getElementsByClassName(piece)[i].style.backgroundImage = url;
  65. console.log("heya");
  66. }
  67. }