IdlePixel Sigil Randomizer

Randomizes sigil after every message

目前为 2023-02-21 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name IdlePixel Sigil Randomizer
  3. // @namespace lbtechnology.info
  4. // @version 1.0.0
  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.  
  17. function randInt(max) {
  18. return Math.floor(Math.random() * max);
  19. }
  20. class SigilPlugin extends IdlePixelPlusPlugin {
  21. constructor() {
  22. super("sigils", {
  23. about: {
  24. name: GM_info.script.name,
  25. version: GM_info.script.version,
  26. author: GM_info.script.author,
  27. description: GM_info.script.description
  28. }
  29. });
  30. this.previous = "";
  31. }
  32. onChat(data) {
  33. if (data.username === username){
  34. IdlePixelPlus.sendMessage('CHAT_SIGIL=' + sigilList[randInt(sigilList.length)])
  35. }
  36. }
  37. onMessageReceived(data){
  38. if(data.startsWith("SET_ITEMS=")){
  39. if (username===""){
  40. const split = data.substring("SET_ITEMS=".length).split("~");
  41. username = split[split.indexOf("username")+1]
  42. split.forEach(element => {
  43. if (element.endsWith("sigil") && element !== "chat_sigil"){
  44. sigilList.push(element)
  45. }
  46. })
  47. }
  48. }
  49. }
  50. }
  51. const plugin = new SigilPlugin();
  52. IdlePixelPlus.registerPlugin(plugin);
  53. })();