Pixelplanet+

Customize the PixelPlanet interface with extended personalization options and revert to default.

目前为 2024-11-12 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Pixelplanet+
  3. // @namespace http://tampermonkey.net/
  4. // @version 3
  5. // @author Pixel, join dsc.gg/turkmenlippf
  6. // @description Customize the PixelPlanet interface with extended personalization options and revert to default.
  7. // @match https://pixelplanet.fun/*
  8. // @grant GM_addStyle
  9. // @icon https://cdn.discordapp.com/attachments/1295091021016862782/1305807684657876992/image.png?ex=67345fac&is=67330e2c&hm=f8dac6f7693c5f04b3e07bcb82e41885ec1bfdae62ae0a39da2739452dcdeff3&
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. // Import Google Fonts
  16. GM_addStyle(`@import url('https://fonts.googleapis.com/css2?family=Pixelify+Sans&display=swap');`);
  17.  
  18. // Define improved default styles
  19. const defaultCSS = `
  20. body {
  21. margin: 0;
  22. font-family: 'Montserrat', sans-serif;
  23. font-size: 16px;
  24. background: #c4c4c4;
  25. }
  26. .menu > div { background-color: transparent !important; }
  27. `;
  28.  
  29. // Load styles and settings on page load
  30. applyStoredStyles();
  31. addCustomizationButton();
  32.  
  33. // Apply stored styles from localStorage
  34. function applyStoredStyles() {
  35. const settings = {
  36. buttonColor: getStoredValue('buttonColor', '#4CAF50'),
  37. buttonHoverColor: getStoredValue('buttonHoverColor', '#ff91a6'),
  38. fontColor: getStoredValue('fontColor', '#000000'),
  39. fontSize: getStoredValue('fontSize', '16'),
  40. fontFamily: getStoredValue('fontFamily', 'Arial'),
  41. menuColor: getStoredValue('menuColor', '#ffffff'),
  42. backgroundOpacity: getStoredValue('backgroundOpacity', '1'),
  43. backgroundImage: getStoredValue('backgroundImage', '')
  44. };
  45. applyCustomStyles(settings);
  46. }
  47.  
  48. // Reset styles
  49. function resetToDefaultStyles() {
  50. localStorage.clear();
  51. GM_addStyle(defaultCSS);
  52. applyStoredStyles();
  53. }
  54.  
  55. // Get and set storage functions
  56. function getStoredValue(key, defaultValue) {
  57. return localStorage.getItem(key) || defaultValue;
  58. }
  59. function setStoredValue(key, value) {
  60. localStorage.setItem(key, value);
  61. }
  62.  
  63. // Apply customization styles to specified elements
  64. function applyCustomStyles({ buttonColor, buttonHoverColor, fontColor, fontSize, fontFamily, menuColor, backgroundOpacity, backgroundImage }) {
  65. GM_addStyle(`
  66. body {
  67. background-color: rgba(255, 255, 255, ${backgroundOpacity});
  68. background-image: url(${backgroundImage});
  69. font-size: ${fontSize}px;
  70. font-family: ${fontFamily};
  71. color: ${fontColor};
  72. }
  73. /* Apply colors to buttons and other elements */
  74. .actionbuttons, .actionbuttons button,
  75. .coorbox, .onlinebox, .cooldownbox, #palettebox {
  76. background-color: ${buttonColor} !important;
  77. color: white !important;
  78. }
  79. .actionbuttons:hover, .actionbuttons button:hover,
  80. .coorbox:hover, .onlinebox:hover, .cooldownbox:hover, #palettebox:hover {
  81. background-color: ${buttonHoverColor} !important;
  82. }
  83. /* Apply colors to modals and menus with the customMenu class */
  84. .customMenu, .modal.USERAREA.show, .modal.HELP.show, .modal.SETTINGS.show {
  85. background-color: ${menuColor} !important;
  86. color: ${fontColor};
  87. border-radius: 10px;
  88. box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
  89. }
  90. `);
  91. }
  92.  
  93. // Create customization button
  94. function addCustomizationButton() {
  95. const customizationButton = document.createElement('div');
  96. customizationButton.id = 'customizationButton';
  97. customizationButton.className = 'actionbuttons';
  98. customizationButton.setAttribute('role', 'button');
  99. customizationButton.innerHTML = `
  100. <svg stroke="currentColor" fill="currentColor" viewBox="0 0 24 24" height="1em" width="1em">
  101. <circle cx="12" cy="12" r="10" style="fill: #FFC107;" />
  102. <text x="12" y="16" text-anchor="middle" fill="white" font-size="10">K</text>
  103. </svg>`;
  104. customizationButton.style.position = 'fixed';
  105. customizationButton.style.left = '16px';
  106. customizationButton.style.top = '37%';
  107. customizationButton.style.zIndex = '9999';
  108. customizationButton.style.transform = 'translateY(-50%)';
  109.  
  110. document.body.appendChild(customizationButton);
  111. customizationButton.addEventListener('click', showCustomizationPanel);
  112. }
  113.  
  114. // Show customization panel with improved styling and new options
  115. function showCustomizationPanel() {
  116. const panelHTML = `
  117. <div class="modal SETTINGS show customMenu" style="
  118. z-index: 9999;
  119. width: 50%;
  120. max-width: 500px;
  121. max-height: 80vh;
  122. overflow-y: auto;
  123. padding: 20px;
  124. position: fixed;
  125. top: 50%;
  126. left: 50%;
  127. transform: translate(-50%, -50%);
  128. background-color: #ffffff;
  129. border: 1px solid #ccc;
  130. border-radius: 12px;
  131. box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
  132. transition: all 0.3s ease;
  133. font-family: 'Pixelify Sans', sans-serif;
  134. ">
  135. <h2 style="text-align: center; font-size: 1.4em; margin-bottom: 1em;">Settings</h2>
  136. <div class="modal-topbtn close" role="button" title="Close" tabindex="-1" style="
  137. position: absolute;
  138. top: 10px;
  139. right: 10px;
  140. font-size: 1.2em;
  141. cursor: pointer;
  142. ">✕</div>
  143. <div class="content" style="display: flex; flex-direction: column; gap: 15px;">
  144. <div class="setitem">
  145. <label>Button Color:</label>
  146. <input type="color" id="buttonColorPicker" value="${getStoredValue('buttonColor', '#4CAF50')}" />
  147. </div>
  148. <div class="setitem">
  149. <label>Button Hover Color:</label>
  150. <input type="color" id="buttonHoverColorPicker" value="${getStoredValue('buttonHoverColor', '#ff91a6')}" />
  151. </div>
  152. <div class="setitem">
  153. <label>Font Color:</label>
  154. <input type="color" id="fontColorPicker" value="${getStoredValue('fontColor', '#000000')}" />
  155. </div>
  156. <div class="setitem">
  157. <label>Font Size:</label>
  158. <input type="number" id="fontSizePicker" min="10" max="30" value="${getStoredValue('fontSize', '16')}" style="width: 80px;" /> px
  159. </div>
  160. <div class="setitem">
  161. <label>Font Family:</label>
  162. <select id="fontFamilyPicker" style="padding: 5px; border-radius: 5px;">
  163. <option value="Arial" ${getStoredValue('fontFamily', 'Arial') === 'Arial' ? 'selected' : ''}>Arial</option>
  164. <option value="Verdana" ${getStoredValue('fontFamily', 'Arial') === 'Verdana' ? 'selected' : ''}>Verdana</option>
  165. <option value="Helvetica" ${getStoredValue('fontFamily', 'Arial') === 'Helvetica' ? 'selected' : ''}>Helvetica</option>
  166. <option value="Tahoma" ${getStoredValue('fontFamily', 'Arial') === 'Tahoma' ? 'selected' : ''}>Tahoma</option>
  167. <option value="Pixelify Sans" ${getStoredValue('fontFamily', 'Arial') === 'Pixelify Sans' ? 'selected' : ''}>Pixelify Sans</option>
  168. </select>
  169. </div>
  170. <div class="setitem">
  171. <label>Menu Color:</label>
  172. <input type="color" id="menuColorPicker" value="${getStoredValue('menuColor', '#ffffff')}" />
  173. </div>
  174. <div class="setitem">
  175. <label>Background Opacity:</label>
  176. <input type="range" id="backgroundOpacity" min="0.1" max="1" step="0.1" value="${getStoredValue('backgroundOpacity', '1')}" />
  177. </div>
  178. <div class="setitem">
  179. <label>Background Image URL:</label>
  180. <input type="text" id="backgroundImage" value="${getStoredValue('backgroundImage', '')}" style="width: 100%; padding: 5px;" />
  181. </div>
  182. <div style="display: flex; justify-content: space-between; margin-top: 1em;">
  183. <button id="saveCustomization" style="flex: 1; margin-right: 5px; padding: 10px; background-color: #4CAF50; color: white; border: none; border-radius: 5px; cursor: pointer; transition: background-color 0.3s;">Save</button>
  184. <button id="resetCustomization" style="flex: 1; margin-left: 5px; padding: 10px; background-color: #f44336; color: white; border: none; border-radius: 5px; cursor: pointer; transition: background-color 0.3s;">Reset</button>
  185. </div>
  186. </div>
  187. </div>`;
  188.  
  189. document.body.insertAdjacentHTML('beforeend', panelHTML);
  190. document.getElementById('saveCustomization').addEventListener('click', saveCustomization);
  191. document.getElementById('resetCustomization').addEventListener('click', resetToDefaultStyles);
  192. document.querySelector('.close').addEventListener('click', hideCustomizationPanel);
  193. }
  194.  
  195. // Save settings
  196. function saveCustomization() {
  197. setStoredValue('buttonColor', document.getElementById('buttonColorPicker').value);
  198. setStoredValue('buttonHoverColor', document.getElementById('buttonHoverColorPicker').value);
  199. setStoredValue('fontColor', document.getElementById('fontColorPicker').value);
  200. setStoredValue('fontSize', document.getElementById('fontSizePicker').value);
  201. setStoredValue('fontFamily', document.getElementById('fontFamilyPicker').value);
  202. setStoredValue('menuColor', document.getElementById('menuColorPicker').value);
  203. setStoredValue('backgroundOpacity', document.getElementById('backgroundOpacity').value);
  204. setStoredValue('backgroundImage', document.getElementById('backgroundImage').value);
  205. applyStoredStyles();
  206. }
  207.  
  208. // Hide panel
  209. function hideCustomizationPanel() {
  210. const panel = document.querySelector('.modal');
  211. if (panel) { panel.remove(); }
  212. }
  213. })();