Pixelplanet+

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

目前为 2024-11-13 提交的版本。查看 最新版本

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