IdlePixel+ Plugin Paneller

Library which creates a modal for opening plugin panels.

此脚本不应直接安装,它是一个供其他脚本使用的外部库。如果您需要使用该库,请在脚本元属性加入:// @require https://update.gf.qytechs.cn/scripts/491983/1368960/IdlePixel%2B%20Plugin%20Paneller.js

  1. // ==UserScript==
  2. // @name IdlePixel+ Plugin Paneller
  3. // @namespace lbtechnology.info
  4. // @version 1.1.0
  5. // @description Library which creates a modal for opening plugin panels.
  6. // @author Lux-Ferre
  7. // @license MIT
  8. // @match *://idle-pixel.com/login/play*
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. if(window.Paneller) {
  14. // already loaded
  15. return;
  16. }
  17.  
  18. class Paneller {
  19. constructor() {
  20. this.registered_panels = []
  21. this.uit_found = 0
  22. this.addStyles()
  23. this.createModal()
  24. this.registerPanel("varviewer", "Var Viewer")
  25. const onlineCount = $(".game-top-bar .gold:not(#top-bar-admin-link)");
  26. onlineCount.before(`<a href="#" class="hover float-end link-no-decoration" id="panellerLink">Panel Selector</a>`);
  27. $("#panellerLink").attr("onclick", "event.preventDefault(); Paneller.showModal()")
  28. }
  29. addStyles(){
  30. $("head").append(`
  31. <style id="styles-paneller">
  32. #panellerLink {
  33. margin: 0 20px;
  34. }
  35. .panellerModalInner {
  36. background-color: white;
  37. color: black;
  38. }
  39.  
  40. #panellerModalHeader {
  41. padding: calc(var(--bs-modal-padding) - var(--bs-modal-header-gap) * .5);
  42. background-color: var(--bs-modal-header-bg);
  43. border-bottom: var(--bs-modal-header-border-width) solid var(--bs-modal-header-border-color);
  44. border-top-right-radius: var(--bs-modal-inner-border-radius);
  45. border-top-left-radius: var(--bs-modal-inner-border-radius);
  46. }
  47.  
  48. #panellerModal .modal-body {
  49. overflow-y: auto;
  50. }
  51. .panellerModalButton {
  52. background-color: RGBA(1, 150, 150, 0.5);
  53. margin-bottom: 2px;
  54. cursor: pointer;
  55. }
  56. .panellerModalText {
  57. margin-left: 20px;
  58. }
  59. #panellerModalDialogue {
  60. margin-top: 20vh;
  61. }
  62. </style>
  63. `)
  64. }
  65. registerPanel(panelName, displayName, target="panel"){
  66. this.registered_panels.push({
  67. name: panelName,
  68. display: displayName,
  69. target: target
  70. })
  71. }
  72. createModal(){
  73. const modalString = `
  74. <div id="panellerModal" class="modal fade" role="dialog" tabindex="-1"">
  75. <div id="panellerModalDialogue" class="modal-dialog" role="document">
  76. <div id="panellerModalInner" class="modal-content panellerModalInner">
  77. <div id="panellerModalHeader" class="modal-header text-center">
  78. <h3 class="modal-title w-100"><u>Panel Selector</u></h3>
  79. </div>
  80. <div class="modal-body">
  81. <div id="panellerModalList" class="overflow-auto"></div>
  82. </div>
  83. </div>
  84. </div>
  85. </div>
  86. `
  87. const modalElement = $.parseHTML(modalString)
  88. $(document.body).append(modalElement)
  89. }
  90. populateModal(){
  91. const panellerModalList = $("#panellerModalList")
  92. panellerModalList.empty()
  93. this.registered_panels.forEach(panel => {
  94. const newItemString = `<div class="d-flex justify-content-between rounded-pill panellerModalButton" data-panelName="${panel.name}"><span class="panellerModalText">${panel.display}</span></div>`
  95. const newItemElement = $.parseHTML(newItemString)
  96. panellerModalList.append(newItemElement)
  97. })
  98.  
  99. $(".panellerModalButton").attr("onclick", "Paneller.switchPanel(this.getAttribute('data-panelName'))")
  100. }
  101. showModal(){
  102. if (this.uit_found === 0){
  103. if ("ui-tweaks" in IdlePixelPlus.plugins){
  104. this.uit_found = 1
  105. const backgroundColour = IdlePixelPlus.plugins["ui-tweaks"].config["color-chat-area"]
  106. const textColour = IdlePixelPlus.plugins["ui-tweaks"].config["font-color-chat-area"]
  107. $("head").append(`
  108. <style id="styles-paneller-annex">
  109. .panellerModalInnerUIT {
  110. background-color: ${backgroundColour};
  111. color: ${textColour};
  112. }
  113. </style>
  114. `)
  115. $("#panellerModalInner").removeClass("panellerModalInner").addClass("panellerModalInnerUIT")
  116. } else {
  117. this.uit_found = -1
  118. }
  119. }
  120. this.populateModal()
  121. document.body.scrollTop = document.documentElement.scrollTop = 0;
  122. $('#panellerModal').modal('show')
  123. }
  124. switchPanel(panelName){
  125. this.registered_panels.forEach(panel=>{
  126. if(panel.name===panelName){
  127. if(panel.target==="panel"){
  128. IdlePixelPlus.setPanel(panelName)
  129. } else {
  130. panel.target.apply()
  131. }
  132. }
  133. })
  134.  
  135. $('#panellerModal').modal('hide')
  136. }
  137. }
  138.  
  139. // Add to window and init
  140. window.Paneller = new Paneller();
  141. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址