GMify

Pretend to be GM

当前为 2023-10-20 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name GMify
  3. // @version 20231020
  4. // @description Pretend to be GM
  5. // @author soup_steward
  6. // @match https://www.chess.com/*
  7. // @match https://chess.com/*
  8. // @require http://code.jquery.com/jquery-latest.js
  9. // @grant none
  10. // @license MIT
  11. // @inject-into content
  12. // @namespace https://greasyfork.org/users/964951
  13. // ==/UserScript==
  14.  
  15. function waitForElm(selector) {
  16. return new Promise(resolve => {
  17. if (document.querySelector(selector)) {
  18. return resolve(document.querySelector(selector));
  19. }
  20.  
  21. const observer = new MutationObserver(mutations => {
  22. if (document.querySelector(selector)) {
  23. resolve(document.querySelector(selector));
  24. observer.disconnect();
  25. }
  26. });
  27.  
  28. observer.observe(document.body, {
  29. childList: true,
  30. subtree: true
  31. });
  32. });
  33. }
  34.  
  35. function setGmStatus(){
  36.  
  37. $('#board-layout-player-bottom > div > div.player-tagline > div.user-tagline-component').prepend('<a href="/members/titled-players" target="_blank" class="user-chess-title-component" data-tooltip-target="10">GM</a>');
  38.  
  39.  
  40. $('#board-layout-player-bottom > div > div.player-tagline > div.player-game-over-component > div > span.rating-score-rating').html(
  41. parseInt($('#board-layout-player-bottom > div > div.player-tagline > div.player-game-over-component > div > span.rating-score-rating').html()) +2000
  42. );
  43.  
  44.  
  45. };
  46.  
  47. waitForElm('.rating-score-rating').then((elm) => {
  48.  
  49. setGmStatus();
  50.  
  51. });