mirror of
https://github.com/SwingTheVine/Wplace-BlueMarble.git
synced 2026-03-11 17:15:38 +00:00
Added Move Palette button
This commit is contained in:
parent
cb6a89c330
commit
5879422b9d
6 changed files with 49 additions and 8 deletions
4
dist/BlueMarble.user.js
vendored
4
dist/BlueMarble.user.js
vendored
File diff suppressed because one or more lines are too long
|
|
@ -35,7 +35,7 @@
|
|||
<a href="https://github.com/SwingTheVine/Wplace-BlueMarble/blob/main/LICENSE.txt" target="_blank"><img alt="Software License: MPL-2.0" src="https://img.shields.io/badge/Software_License-MPL--2.0-slateblue?style=flat"></a>
|
||||
<a href="https://discord.gg/tpeBPy46hf" target="_blank"><img alt="Contact Me" src="https://img.shields.io/badge/Contact_Me-gray?style=flat&logo=Discord&logoColor=white&logoSize=auto&labelColor=cornflowerblue"></a>
|
||||
<a href="" target="_blank"><img alt="WakaTime" src="https://img.shields.io/badge/Coding_Time-87hrs_0mins-blue?style=flat&logo=wakatime&logoColor=black&logoSize=auto&labelColor=white"></a>
|
||||
<a href="" target="_blank"><img alt="Total Patches" src="https://img.shields.io/badge/Total_Patches-436-black?style=flat"></a>
|
||||
<a href="" target="_blank"><img alt="Total Patches" src="https://img.shields.io/badge/Total_Patches-438-black?style=flat"></a>
|
||||
<a href="" target="_blank"><img alt="Total Lines of Code" src="https://tokei.rs/b1/github/SwingTheVine/Wplace-BlueMarble?category=code"></a>
|
||||
<a href="" target="_blank"><img alt="Total Comments" src="https://tokei.rs/b1/github/SwingTheVine/Wplace-BlueMarble?category=comments"></a>
|
||||
<a href="" target="_blank"><img alt="Compression" src="https://img.shields.io/badge/Compression-73.47%25-blue"></a>
|
||||
|
|
|
|||
4
package-lock.json
generated
4
package-lock.json
generated
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "wplace-bluemarble",
|
||||
"version": "0.66.2",
|
||||
"version": "0.66.4",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "wplace-bluemarble",
|
||||
"version": "0.66.2",
|
||||
"version": "0.66.4",
|
||||
"devDependencies": {
|
||||
"esbuild": "^0.25.0",
|
||||
"terser": "^5.43.1"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "wplace-bluemarble",
|
||||
"version": "0.66.2",
|
||||
"version": "0.66.4",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"build": "node build/build.js",
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
// ==UserScript==
|
||||
// @name Blue Marble
|
||||
// @namespace https://github.com/SwingTheVine/
|
||||
// @version 0.66.2
|
||||
// @version 0.66.4
|
||||
// @description A userscript to automate and/or enhance the user experience on Wplace.live. Make sure to comply with the site's Terms of Service, and rules! This script is not affiliated with Wplace.live in any way, use at your own risk. This script is not affiliated with TamperMonkey. The author of this userscript is not responsible for any damages, issues, loss of data, or punishment that may occur as a result of using this script. This script is provided "as is" under the MPL-2.0 license. The "Blue Marble" icon is licensed under CC0 1.0 Universal (CC0 1.0) Public Domain Dedication. The image is owned by NASA.
|
||||
// @author SwingTheVine
|
||||
// @license MPL-2.0
|
||||
|
|
|
|||
43
src/main.js
43
src/main.js
|
|
@ -62,7 +62,7 @@ inject(() => {
|
|||
|
||||
consoleWarn(`%c${name}%c: Attempted to retrieve a blob (%s) from queue, but the blobID was not a function! Skipping...`, consoleStyle, '', blobID);
|
||||
}
|
||||
|
||||
|
||||
fetchedBlobQueue.delete(blobID); // Delete the blob from the queue, because we don't need to process it again
|
||||
}
|
||||
});
|
||||
|
|
@ -186,8 +186,49 @@ overlay.handleDrag('#bm-overlay', '#bm-bar-drag'); // Creates dragging capabilit
|
|||
|
||||
apiManager.spontaneousResponseListener(overlay); // Reads spontaneous fetch responces
|
||||
|
||||
observeBlack(); // Observes the black palette color
|
||||
|
||||
consoleLog(`%c${name}%c (${version}) userscript has loaded!`, 'color: cornflowerblue;', '');
|
||||
|
||||
/** Observe the black color, and add the "Move" button.
|
||||
* @since 0.66.3
|
||||
*/
|
||||
function observeBlack() {
|
||||
const observer = new MutationObserver((mutations, observer) => {
|
||||
|
||||
const black = document.querySelector('#color-1'); // Attempt to retrieve the black color element for anchoring
|
||||
|
||||
if (!black) {return;} // Black color does not exist yet. Kills iteself
|
||||
|
||||
let move = document.querySelector('#bm-button-move'); // Tries to find the move button
|
||||
|
||||
// If the move button does not exist, we make a new one
|
||||
if (!move) {
|
||||
move = document.createElement('button');
|
||||
move.id = 'bm-button-move';
|
||||
move.textContent = 'Move ↑';
|
||||
move.className = 'btn btn-soft';
|
||||
move.onclick = function() {
|
||||
const roundedBox = this.parentNode.parentNode.parentNode.parentNode; // Obtains the rounded box
|
||||
const shouldMoveUp = (this.textContent == 'Move ↑');
|
||||
roundedBox.parentNode.className = roundedBox.parentNode.className.replace(shouldMoveUp ? 'bottom' : 'top', shouldMoveUp ? 'top' : 'bottom'); // Moves the rounded box to the top
|
||||
roundedBox.style.borderTopLeftRadius = shouldMoveUp ? '0px' : 'var(--radius-box)';
|
||||
roundedBox.style.borderTopRightRadius = shouldMoveUp ? '0px' : 'var(--radius-box)';
|
||||
roundedBox.style.borderBottomLeftRadius = shouldMoveUp ? 'var(--radius-box)' : '0px';
|
||||
roundedBox.style.borderBottomRightRadius = shouldMoveUp ? 'var(--radius-box)' : '0px';
|
||||
this.textContent = shouldMoveUp ? 'Move ↓' : 'Move ↑';
|
||||
}
|
||||
|
||||
// Attempts to find the "Paint Pixel" element for anchoring
|
||||
const paintPixel = black.parentNode.parentNode.parentNode.parentNode.querySelector('h2');
|
||||
|
||||
paintPixel.parentNode.appendChild(move); // Adds the move button
|
||||
}
|
||||
});
|
||||
|
||||
observer.observe(document.body, { childList: true, subtree: true });
|
||||
}
|
||||
|
||||
/** Deploys the overlay to the page.
|
||||
* Parent/child relationships in the DOM structure below are indicated by indentation.
|
||||
* @since 0.58.3
|
||||
|
|
|
|||
Loading…
Reference in a new issue