🏠 Home 

IdlePixelPlus Config Backup

Creates a panel for backing up IP+ Configs


安装此脚本?
  1. // ==UserScript==
  2. // @name IdlePixelPlus Config Backup
  3. // @namespace lbtechnology.info
  4. // @version 1.1.0
  5. // @description Creates a panel for backing up IP+ Configs
  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. class IPPBackupPlugin extends IdlePixelPlusPlugin {
  15. constructor() {
  16. super("IPPBackup", {
  17. about: {
  18. name: GM_info.script.name,
  19. version: GM_info.script.version,
  20. author: GM_info.script.author,
  21. description: GM_info.script.description
  22. }
  23. });
  24. this.previous = "";
  25. }
  26. createPanel(){
  27. IdlePixelPlus.addPanel("ippbackup", "Backup/Restore Panel", function() {
  28. let content = `<div>`
  29. content += `<br/>`
  30. IdlePixelPlus.forEachPlugin(plugin=>{
  31. const id = plugin.id
  32. content += `<div>`
  33. content += `<label for='${id}_text'><p style="-webkit-text-stroke:1px cadetblue;">${id}:&nbsp&nbsp</p></label>`
  34. content += `<input id="${id}_text" type="text" style="width: 90%; float:right" readonly>`
  35. content += `</div>`
  36. })
  37. content += `<input type="button" value="Load All" onClick="IdlePixelPlus.plugins.IPPBackup.loadAll()" id="load_all_button">`
  38. content += `<input type="button" value="Restore" onClick="IdlePixelPlus.plugins.IPPBackup.restoreAll()" id="restore_all_button">`
  39. content += `</div>`
  40. content += `<div>`
  41. content += `<label for='allConfigs'><p style="-webkit-text-stroke:1px cadetblue;">All Configs:&nbsp&nbsp</p></label>`
  42. content += `<input id="allConfigs" type="text" style="width: 90%; float:right" readonly>`
  43. content += `</div>`
  44. return content
  45. });
  46. }
  47. loadAll(){
  48. var data = {}
  49. IdlePixelPlus.forEachPlugin(plugin=>{
  50. var sub_data = {}
  51. const id = plugin.id
  52. const plugin_textbox = `#${id}_text`
  53. let stored = localStorage.getItem(`idlepixelplus.${id}.config`);
  54. if (stored == null){
  55. sub_data = "";
  56. }
  57. else {
  58. sub_data[id] = stored
  59. data[id] = stored;
  60. }
  61. $(plugin_textbox).val(JSON.stringify(sub_data))
  62. })
  63. const allConfigs = $("#allConfigs")
  64. allConfigs.val(JSON.stringify(data))
  65. }
  66. restoreAll(){
  67. var data = {}
  68. const raw_input = prompt("Paste backup here:")
  69. if (raw_input == null){return;}
  70. const config_obj = JSON.parse(raw_input)
  71. for (const [key, value] of Object.entries(config_obj)) {
  72. localStorage.setItem(`idlepixelplus.${key}.config`, value);
  73. }
  74. }
  75. onLogin(){
  76. this.createPanel()
  77. const lastMenuItem = $("#menu-bar-buttons > .hover-menu-bar-item").last();
  78. lastMenuItem.after(`
  79. <div onclick="IdlePixelPlus.setPanel('ippbackup')" class="hover hover-menu-bar-item">
  80. <p>💾 PLUGIN BACKUP</p>
  81. </div>
  82. `)
  83. }
  84. }
  85. const plugin = new IPPBackupPlugin();
  86. IdlePixelPlus.registerPlugin(plugin);
  87. })();