diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a1bed39..7e8bb33 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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]" diff --git a/BlueMarble.meta.js b/BlueMarble.meta.js index 5684955..2cca8c9 100644 --- a/BlueMarble.meta.js +++ b/BlueMarble.meta.js @@ -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== \ No newline at end of file +// @link https://wplace.live +// @link https://www.mozilla.org/en-US/MPL/2.0/ +// ==/UserScript== diff --git a/BlueMarble.user.js b/BlueMarble.user.js deleted file mode 100644 index 5c7761f..0000000 --- a/BlueMarble.user.js +++ /dev/null @@ -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
element - - div.textContent = this.text; // Sets the text content of the
to the passed-in text - - // Styles the
- 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
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); -})(); diff --git a/build.js b/build.js new file mode 100644 index 0000000..c22937b --- /dev/null +++ b/build.js @@ -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)); \ No newline at end of file diff --git a/dist/BlueMarble.user.js b/dist/BlueMarble.user.js index e69de29..f0ba6c2 100644 --- a/dist/BlueMarble.user.js +++ b/dist/BlueMarble.user.js @@ -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);})(); diff --git a/package-lock.json b/package-lock.json index d7db721..138f7d7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -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" } diff --git a/package.json b/package.json index b9b27d7..13511a7 100644 --- a/package.json +++ b/package.json @@ -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" diff --git a/src/main.js b/src/main.js new file mode 100644 index 0000000..e724b63 --- /dev/null +++ b/src/main.js @@ -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); \ No newline at end of file diff --git a/src/overlay.js b/src/overlay.js new file mode 100644 index 0000000..efd2f2f --- /dev/null +++ b/src/overlay.js @@ -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
element + + div.textContent = this.text; // Sets the text content of the
to the passed-in text + + // Styles the
+ 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
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 + } + } +} \ No newline at end of file diff --git a/update-version.js b/update-version.js new file mode 100644 index 0000000..c9c657f --- /dev/null +++ b/update-version.js @@ -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}`); \ No newline at end of file