IdlePixel Shut Up, Alt

Never accidentally send a message on an alt again

目前为 2023-10-19 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name IdlePixel Shut Up, Alt
  3. // @namespace com.zlef.idlepixel
  4. // @version 1.0.0
  5. // @description Never accidentally send a message on an alt again
  6. // @author Zlef
  7. // @license MIT
  8. // @match *://idle-pixel.com/login/play*
  9. // @grant none
  10. // @require https://greasyfork.org/scripts/441206-idlepixel/code/IdlePixel+.js?anticache=20220905
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15.  
  16. class ShutUpAlt extends IdlePixelPlusPlugin {
  17. constructor() {
  18. super("shutupalt", {
  19. about: {
  20. name: GM_info.script.name + " (ver: " + GM_info.script.version + ")",
  21. version: GM_info.script.version,
  22. author: GM_info.script.author,
  23. description: GM_info.script.description
  24. },
  25. config: [
  26. {
  27. id: "confused",
  28. label: "I have no idea how to only have one config so here's a checkbox to play with",
  29. type: "boolean",
  30. default: true
  31. },
  32. {
  33. id: "altIDList",
  34. label: "List the player ID of alts you dont want to see in the player market.",
  35. type: "string",
  36. max: 200000,
  37. default: "PlaceIDsHere"
  38. }
  39. ]
  40. });
  41.  
  42.  
  43. }
  44.  
  45. onConfigsChanged() {
  46. this.getConfig("altNames");
  47. // Pinched from MarketOverhaul:
  48. this.chatDisabledList = IdlePixelPlus.plugins.shutupalt.getConfig("altIDList").replace(";",",").replace(" ,", ",").replace(" , ",",").replace(", ",",").toLowerCase();
  49. this.disableChat();
  50. }
  51.  
  52. onLogin() {
  53. this.username = document.querySelector('item-display[data-key="username"]').innerText;
  54. // Pinched from MarketOverhaul:
  55. this.chatDisabledList = IdlePixelPlus.plugins.shutupalt.getConfig("altIDList").replace(";",",").replace(" ,", ",").replace(" , ",",").replace(", ",",").toLowerCase();
  56. this.disableChat();
  57.  
  58. }
  59.  
  60. disableChat(){
  61. const chatInput = document.querySelector('.chat-area-input');
  62. if (this.chatDisabledList.includes(this.username.toLowerCase())) {
  63. chatInput.setAttribute('disabled', 'disabled');
  64. chatInput.setAttribute('placeholder', `${this.username} (Chat disabled)`);
  65. } else {
  66. chatInput.removeAttribute('disabled');
  67. chatInput.setAttribute('placeholder', this.username);
  68. }
  69. }
  70.  
  71. }
  72.  
  73. const plugin = new ShutUpAlt();
  74. IdlePixelPlus.registerPlugin(plugin);
  75.  
  76. })();