IdlePixel Sigil Randomizer

Randomizes sigil after every message

当前为 2023-04-22 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name IdlePixel Sigil Randomizer
  3. // @namespace lbtechnology.info
  4. // @version 1.1.1
  5. // @description Randomizes sigil after every message
  6. // @author Lux-Ferre
  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. (function() {
  13. 'use strict';
  14. let sigilList = []
  15. let username = ""
  16. const hardcodedArrayOfBrokenSigilsBecauseSmitty = [
  17. "chat_sigil",
  18. "bat_bat_caves_sigil",
  19. "floating_skull_skull_sigil",
  20. "blood_spider_spider_fields_sigil",
  21. "spider_spider_fields_sigil",
  22. ]
  23.  
  24. function randInt(max) {
  25. return Math.floor(Math.random() * max);
  26. }
  27. class SigilPlugin extends IdlePixelPlusPlugin {
  28. constructor() {
  29. super("sigils", {
  30. about: {
  31. name: GM_info.script.name,
  32. version: GM_info.script.version,
  33. author: GM_info.script.author,
  34. description: GM_info.script.description
  35. },
  36. config: [{
  37. id: "activeNames",
  38. label: "List of your accounts that have the randomizer active (leave empty for all.)",
  39. type: "string",
  40. max: 2000,
  41. default: ""
  42. },
  43. {
  44. id: "randomizerEnabled",
  45. label: "Randomizer enabled?",
  46. type: "boolean",
  47. default: true
  48. }]
  49. });
  50. this.previous = "";
  51. }
  52. onChat(data) {
  53. const nameList = this.getConfig("activeNames");
  54. const randomizerEnabled = this.getConfig("randomizerEnabled");
  55. if(randomizerEnabled){
  56. if (nameList.includes(username) || nameList == "") {
  57. if (data.username === username){
  58. IdlePixelPlus.sendMessage('CHAT_SIGIL=' + sigilList[randInt(sigilList.length)])
  59. }
  60. }
  61. }
  62. }
  63. onMessageReceived(data){
  64. if(data.startsWith("SET_ITEMS=")){
  65. if (username===""){
  66. const split = data.substring("SET_ITEMS=".length).split("~");
  67. username = split[split.indexOf("username")+1]
  68. split.forEach(element => {
  69. if (element.endsWith("sigil") && !hardcodedArrayOfBrokenSigilsBecauseSmitty.includes(element)){
  70. sigilList.push(element)
  71. }
  72. })
  73. }
  74. }
  75. }
  76. }
  77. const plugin = new SigilPlugin();
  78. IdlePixelPlus.registerPlugin(plugin);
  79. })();