IdlePixel Notes Panel

Adds a panel for storing semi-persistant notes

当前为 2024-04-10 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name IdlePixel Notes Panel
  3. // @namespace lbtechnology.info
  4. // @version 1.1.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%;background-color:rgb(25,25,25);color:rgb(255,255,255)"></textarea>`
  35. content += `<input type="submit" value="Save">`
  36. content += `</form>`
  37. content += `</div>`
  38. return content
  39. });
  40. }
  41.  
  42. onLogin(){
  43. const onlineCount = $(".top-bar .gold:not(#top-bar-admin-link)");
  44. onlineCount.before(`
  45. <a href="#" class="hover float-end link-no-decoration" onclick="event.preventDefault(); IdlePixelPlus.plugins.notespanel.openNotesPanel()" title="Note Taking">Notes&nbsp;&nbsp;&nbsp;</a>
  46. `);
  47. this.createPanel()
  48. }
  49.  
  50. saveNotes(){
  51. const currentNotes = $("#notes_box").val()
  52. localStorage.setItem("IPNotes", currentNotes)
  53. }
  54.  
  55. openNotesPanel(){
  56. const notes = localStorage.getItem("IPNotes")
  57. $("#notes_box").val(notes)
  58. IdlePixelPlus.setPanel('notes')
  59. }
  60. }
  61.  
  62. const plugin = new NotePanelPlugin();
  63. IdlePixelPlus.registerPlugin(plugin);
  64.  
  65. })();