mirror of
https://github.com/SwingTheVine/Wplace-BlueMarble.git
synced 2026-03-11 17:15:38 +00:00
Updated workflow
This commit is contained in:
parent
93dd6cf195
commit
4cb839157b
10 changed files with 140 additions and 107 deletions
5
.github/workflows/build.yml
vendored
5
.github/workflows/build.yml
vendored
|
|
@ -24,6 +24,11 @@ jobs:
|
|||
- name: Build userscript
|
||||
run: npm run build
|
||||
|
||||
- name: Update userscript version
|
||||
run: |
|
||||
npm version minor --no-git-tag-version
|
||||
node update-version.js
|
||||
|
||||
- name: Commit and push built script
|
||||
run: |
|
||||
git config user.name "github-actions[bot]"
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
// ==UserScript==
|
||||
// @name Blue Marble
|
||||
// @namespace https://github.com/SwingTheVine/
|
||||
// @version 0.0.2
|
||||
// @description A userscript for Wplace.live
|
||||
// @version 0.0.6
|
||||
// @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
|
||||
// @supportURL https://discord.gg/tpeBPy46hf
|
||||
|
|
@ -11,4 +11,6 @@
|
|||
// @updateURL https://raw.githubusercontent.com/SwingTheVine/Wplace-BlueMarble/main/BlueMarble.user.js
|
||||
// @downloadURL https://raw.githubusercontent.com/SwingTheVine/Wplace-BlueMarble/main/BlueMarble.user.js
|
||||
// @match *://*.wplace.live/*
|
||||
// ==/UserScript==
|
||||
// @link https://wplace.live
|
||||
// @link https://www.mozilla.org/en-US/MPL/2.0/
|
||||
// ==/UserScript==
|
||||
|
|
|
|||
|
|
@ -1,101 +0,0 @@
|
|||
// ==UserScript==
|
||||
// @name Blue Marble
|
||||
// @namespace https://github.com/SwingTheVine/
|
||||
// @version 0.0.2
|
||||
// @description A userscript for Wplace.live
|
||||
// @author SwingTheVine
|
||||
// @license MPL-2.0
|
||||
// @supportURL https://discord.gg/tpeBPy46hf
|
||||
// @homepageURL https://github.com/SwingTheVine/Wplace-BlueMarble
|
||||
// @icon https://raw.githubusercontent.com/SwingTheVine/Wplace-BlueMarble/main/Favicon.png
|
||||
// @updateURL https://raw.githubusercontent.com/SwingTheVine/Wplace-BlueMarble/main/BlueMarble.user.js
|
||||
// @downloadURL https://raw.githubusercontent.com/SwingTheVine/Wplace-BlueMarble/main/BlueMarble.user.js
|
||||
// @match *://*.wplace.live/*
|
||||
// ==/UserScript==
|
||||
|
||||
/** This script is designed 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.
|
||||
* The author 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
|
||||
* @version 0.0.2
|
||||
* @description A userscript for Wplace.live
|
||||
* @license MPL-2.0
|
||||
* @link https://wplace.live
|
||||
* @link https://github.com/SwingTheVine/Wplace-BlueMarble
|
||||
* @link https://www.mozilla.org/en-US/MPL/2.0/
|
||||
*/
|
||||
|
||||
console.log("Blue Marble script has loaded.");
|
||||
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
/** The overlay for the Blue Marble script.
|
||||
* @since 0.0.2
|
||||
* @description Thie class handles the overlay UI for the Blue Marble script.
|
||||
* @class Overlay
|
||||
*/
|
||||
class Overlay {
|
||||
|
||||
/** Constructor for the Overlay class.
|
||||
* @param {*} text - The text to display in the overlay.
|
||||
* @since 0.0.2
|
||||
* @see {@link Overlay}
|
||||
*/
|
||||
constructor(text) {
|
||||
this.text = text;
|
||||
this.element = null;
|
||||
}
|
||||
|
||||
/** Creates and deploys the overlay element
|
||||
* @since 0.0.2
|
||||
*/
|
||||
create() {
|
||||
|
||||
const div = document.createElement('div'); // Creates a new <div> element
|
||||
|
||||
div.textContent = this.text; // Sets the text content of the <div> to the passed-in text
|
||||
|
||||
// Styles the <div>
|
||||
Object.assign(div.style, {
|
||||
position: 'fixed',
|
||||
top: '10px',
|
||||
right: '10px',
|
||||
backgroundColor: 'rgba(0,0,0,0.7)',
|
||||
color: 'white',
|
||||
padding: '10px',
|
||||
borderRadius: '8px',
|
||||
zIndex: '9999',
|
||||
fontFamily: 'sans-serif'
|
||||
});
|
||||
|
||||
document.body.appendChild(div); // Adds the <div> to the body of the webpage
|
||||
|
||||
this.element = div; // Stores the state of the overlay element in the "element" variable
|
||||
}
|
||||
|
||||
/** Updates the display text of the overlay.
|
||||
* @param {*} newText - New text to populate the overlay with.
|
||||
* @since 0.0.2
|
||||
*/
|
||||
updateText(newText) {
|
||||
|
||||
// If the element exists...
|
||||
if (this.element) {
|
||||
|
||||
this.element.textContent = newText; // ...update the text content
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const overlay = new Overlay("Blue Marble");
|
||||
overlay.create();
|
||||
|
||||
setTimeout(() => {
|
||||
overlay.updateText("Updated text");
|
||||
}, 5000);
|
||||
})();
|
||||
28
build.js
Normal file
28
build.js
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
import esbuild from 'esbuild';
|
||||
import fs from 'fs';
|
||||
import { execSync } from 'child_process';
|
||||
|
||||
try {
|
||||
// Run `npm version patch` synchronously, capturing the output
|
||||
const output = execSync('npm version patch --no-git-tag-version', { stdio: 'inherit' });
|
||||
console.log('Version bumped successfully');
|
||||
const update = execSync('node update-version.js', { stdio: 'inherit' });
|
||||
console.log('Version updated in meta file successfully');
|
||||
} catch (error) {
|
||||
console.error('Failed to bump version:', error);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const metaContent = fs.readFileSync('BlueMarble.meta.js', 'utf8');
|
||||
|
||||
esbuild.build({
|
||||
entryPoints: ['src/main.js'],
|
||||
bundle: true,
|
||||
outfile: 'dist/BlueMarble.user.js',
|
||||
format: 'iife',
|
||||
banner: {
|
||||
js: metaContent
|
||||
},
|
||||
legalComments: 'inline',
|
||||
minify: true
|
||||
}).catch(() => process.exit(1));
|
||||
18
dist/BlueMarble.user.js
vendored
18
dist/BlueMarble.user.js
vendored
|
|
@ -0,0 +1,18 @@
|
|||
// ==UserScript==
|
||||
// @name Blue Marble
|
||||
// @namespace https://github.com/SwingTheVine/
|
||||
// @version 0.0.6
|
||||
// @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
|
||||
// @supportURL https://discord.gg/tpeBPy46hf
|
||||
// @homepageURL https://github.com/SwingTheVine/Wplace-BlueMarble
|
||||
// @icon https://raw.githubusercontent.com/SwingTheVine/Wplace-BlueMarble/main/Favicon.png
|
||||
// @updateURL https://raw.githubusercontent.com/SwingTheVine/Wplace-BlueMarble/main/BlueMarble.user.js
|
||||
// @downloadURL https://raw.githubusercontent.com/SwingTheVine/Wplace-BlueMarble/main/BlueMarble.user.js
|
||||
// @match *://*.wplace.live/*
|
||||
// @link https://wplace.live
|
||||
// @link https://www.mozilla.org/en-US/MPL/2.0/
|
||||
// ==/UserScript==
|
||||
|
||||
(()=>{var t=class{constructor(e){this.text=e,this.element=null}create(){let e=document.createElement("div");e.textContent=this.text,Object.assign(e.style,{position:"fixed",top:"10px",right:"10px",backgroundColor:"rgba(0,0,0,0.7)",color:"white",padding:"10px",borderRadius:"8px",zIndex:"9999",fontFamily:"sans-serif"}),document.body.appendChild(e),this.element=e}updateText(e){this.element&&(this.element.textContent=e)}};console.log("Blue Marble script has loaded.");var o=new t("Blue Marble");o.create();setTimeout(()=>{o.updateText("Updated text")},5e3);})();
|
||||
6
package-lock.json
generated
6
package-lock.json
generated
|
|
@ -6,7 +6,8 @@
|
|||
"": {
|
||||
"devDependencies": {
|
||||
"esbuild": "^0.25.0"
|
||||
}
|
||||
},
|
||||
"version": "0.0.6"
|
||||
},
|
||||
"node_modules/@esbuild/aix-ppc64": {
|
||||
"version": "0.25.8",
|
||||
|
|
@ -465,5 +466,6 @@
|
|||
"@esbuild/win32-x64": "0.25.8"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"version": "0.0.6"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
{
|
||||
"name": "wplace-bluemarble",
|
||||
"version": "0.0.6",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"build": "esbuild src/main.js --bundle --outfile=dist/myscript.user.js --format=iife --banner:js='$(cat BlueMarble.meta.js)'"
|
||||
"build": "node build.js"
|
||||
},
|
||||
"devDependencies": {
|
||||
"esbuild": "^0.25.0"
|
||||
|
|
|
|||
10
src/main.js
Normal file
10
src/main.js
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
import { Overlay } from './overlay.js';
|
||||
|
||||
console.log("Blue Marble script has loaded.");
|
||||
|
||||
const overlay = new Overlay("Blue Marble");
|
||||
overlay.create();
|
||||
|
||||
setTimeout(() => {
|
||||
overlay.updateText("Updated text");
|
||||
}, 5000);
|
||||
56
src/overlay.js
Normal file
56
src/overlay.js
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
/** The overlay for the Blue Marble script.
|
||||
* @since 0.0.2
|
||||
* @description Thie class handles the overlay UI for the Blue Marble script.
|
||||
*/
|
||||
export class Overlay {
|
||||
|
||||
/** Constructor for the Overlay class.
|
||||
* @param {*} text - The text to display in the overlay.
|
||||
* @since 0.0.2
|
||||
* @see {@link Overlay}
|
||||
*/
|
||||
constructor(text) {
|
||||
this.text = text;
|
||||
this.element = null;
|
||||
}
|
||||
|
||||
/** Creates and deploys the overlay element
|
||||
* @since 0.0.2
|
||||
*/
|
||||
create() {
|
||||
|
||||
const div = document.createElement('div'); // Creates a new <div> element
|
||||
|
||||
div.textContent = this.text; // Sets the text content of the <div> to the passed-in text
|
||||
|
||||
// Styles the <div>
|
||||
Object.assign(div.style, {
|
||||
position: 'fixed',
|
||||
top: '10px',
|
||||
right: '10px',
|
||||
backgroundColor: 'rgba(0,0,0,0.7)',
|
||||
color: 'white',
|
||||
padding: '10px',
|
||||
borderRadius: '8px',
|
||||
zIndex: '9999',
|
||||
fontFamily: 'sans-serif'
|
||||
});
|
||||
|
||||
document.body.appendChild(div); // Adds the <div> to the body of the webpage
|
||||
|
||||
this.element = div; // Stores the state of the overlay element in the "element" variable
|
||||
}
|
||||
|
||||
/** Updates the display text of the overlay.
|
||||
* @param {*} newText - New text to populate the overlay with.
|
||||
* @since 0.0.2
|
||||
*/
|
||||
updateText(newText) {
|
||||
|
||||
// If the element exists...
|
||||
if (this.element) {
|
||||
|
||||
this.element.textContent = newText; // ...update the text content
|
||||
}
|
||||
}
|
||||
}
|
||||
10
update-version.js
Normal file
10
update-version.js
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
import fs from 'fs';
|
||||
|
||||
const pkg = JSON.parse(fs.readFileSync('package.json', 'utf-8'));
|
||||
const version = pkg.version;
|
||||
|
||||
let meta = fs.readFileSync('BlueMarble.meta.js', 'utf-8');
|
||||
meta = meta.replace(/@version\s+[\d.]+/, `@version ${version}`);
|
||||
|
||||
fs.writeFileSync('BlueMarble.meta.js', meta);
|
||||
console.log(`Updated userscript version to ${version}`);
|
||||
Loading…
Reference in a new issue