IdlePixel Notes Panel

Adds a panel for storing semi-persistant notes

当前为 2023-09-07 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name IdlePixel Notes Panel
  3. // @namespace lbtechnology.info
  4. // @version 1.0.0
  5. // @description Adds a panel for storing semi-persistant notes
  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.  
  13. (function() {
  14. 'use strict';
  15.  
  16. class NotePanelPlugin extends IdlePixelPlusPlugin {
  17. constructor() {
  18. super("notespanel", {
  19. about: {
  20. name: GM_info.script.name,
  21. version: GM_info.script.version,
  22. author: GM_info.script.author,
  23. description: GM_info.script.description
  24. },
  25. });
  26. this.previous = "";
  27. }
  28.  
  29. createPanel(){
  30. IdlePixelPlus.addPanel("notes", "Notes", function() {
  31. let content = `<div>`
  32. content += `<br/>`
  33. content += `<form onsubmit='event.preventDefault(); IdlePixelPlus.plugins.notespanel.saveNotes()'>`
  34. content += `<textarea id="notes_box" maxlength="2000" style="width:100%;height:75%"></textarea>`
  35. content += `<input type="submit" value="Save">`
  36. content += `</div>`
  37. return content
  38. });
  39. }
  40.  
  41. onLogin(){
  42. const onlineCount = $(".top-bar .gold:not(#top-bar-admin-link)");
  43. onlineCount.before(`
  44. <a href="#" class="hover float-end link-no-decoration" onclick="event.preventDefault(); IdlePixelPlus.plugins.notespanel.openNotesPanel()" title="Note Taking">Notes&nbsp;&nbsp;&nbsp;</a>
  45. `);
  46. this.createPanel()
  47. }
  48.  
  49. saveNotes(){
  50. const currentNotes = $("#notes_box").val()
  51. localStorage.setItem("IPNotes", currentNotes)
  52. }
  53.  
  54. openNotesPanel(){
  55. const notes = localStorage.getItem("IPNotes")
  56. $("#notes_box").val(notes)
  57. IdlePixelPlus.setPanel('notes')
  58. }
  59. }
  60.  
  61. const plugin = new NotePanelPlugin();
  62. IdlePixelPlus.registerPlugin(plugin);
  63.  
  64. })();