mirror of
https://github.com/SwingTheVine/Wplace-BlueMarble.git
synced 2026-01-11 22:40:18 +00:00
25 lines
No EOL
23 KiB
JavaScript
25 lines
No EOL
23 KiB
JavaScript
// ==UserScript==
|
||
// @name Blue Marble
|
||
// @namespace https://github.com/SwingTheVine/
|
||
// @version 0.78.0
|
||
// @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/0d5b710473581e449b16a1e77c75ed287286881a/dist/assets/Favicon.png
|
||
// @updateURL https://raw.githubusercontent.com/SwingTheVine/Wplace-BlueMarble/main/dist/BlueMarble.user.js
|
||
// @downloadURL https://raw.githubusercontent.com/SwingTheVine/Wplace-BlueMarble/main/dist/BlueMarble.user.js
|
||
// @run-at document-start
|
||
// @match *://*.wplace.live/*
|
||
// @grant GM_getResourceText
|
||
// @grant GM_addStyle
|
||
// @grant GM.setValue
|
||
// @grant GM_getValue
|
||
// @resource CSS-BM-File https://raw.githubusercontent.com/SwingTheVine/Wplace-BlueMarble/0d5b710473581e449b16a1e77c75ed287286881a/dist/BlueMarble.user.css
|
||
// ==/UserScript==
|
||
|
||
// Wplace --> https://wplace.live
|
||
// License --> https://www.mozilla.org/en-US/MPL/2.0/
|
||
|
||
(()=>{var t,e,n=t=>{throw TypeError(t)},i=(t,e,i)=>e.has(t)?n("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,i),o=(t,e,i)=>(((t,e)=>{e.has(t)||n("Cannot access private method")})(t,e),i),s=class{constructor(e,n){i(this,t),this.name=e,this.version=n,this.t=null,this.i="bm-b",this.o=null,this.l=null,this.h=[]}m(t){this.t=t}u(){return this.h.length>0&&(this.l=this.h.pop()),this}p(t){t?.appendChild(this.o),this.o=null,this.l=null,this.h=[]}$(n={},i=()=>{}){return i(this,o(this,t,e).call(this,"div",{},n)),this}v(n={},i=()=>{}){return i(this,o(this,t,e).call(this,"p",{},n)),this}M(n={},i=()=>{}){return i(this,o(this,t,e).call(this,"small",{},n)),this}S(n={},i=()=>{}){return i(this,o(this,t,e).call(this,"img",{},n)),this}T(n,i={},s=()=>{}){return s(this,o(this,t,e).call(this,"h"+n,{},i)),this}D(n={},i=()=>{}){return i(this,o(this,t,e).call(this,"hr",{},n)),this}C(n={},i=()=>{}){return i(this,o(this,t,e).call(this,"br",{},n)),this}I(n={},i=()=>{}){const s=o(this,t,e).call(this,"label",{textContent:n.textContent??""});delete n.textContent;const a=o(this,t,e).call(this,"input",{type:"checkbox"},n);return s.insertBefore(a,s.firstChild),this.u(),i(this,s,a),this}k(n={},i=()=>{}){return i(this,o(this,t,e).call(this,"button",{},n)),this}N(n={},i=()=>{}){const s=n.title??n.textContent??"Help: No info";delete n.textContent,n.title=`Help: ${s}`;const a={textContent:"?",className:"bm-q",onclick:()=>{this.B(this.i,s)}};return i(this,o(this,t,e).call(this,"button",a,n)),this}O(n={},i=()=>{}){return i(this,o(this,t,e).call(this,"input",{},n)),this}P(n={},i=()=>{}){const s=n.textContent??"";delete n.textContent;const a=o(this,t,e).call(this,"div"),r=o(this,t,e).call(this,"input",{type:"file",style:"display: none !important; visibility: hidden !important; position: absolute !important; left: -9999px !important; width: 0 !important; height: 0 !important; opacity: 0 !important;"},n);this.u();const c=o(this,t,e).call(this,"button",{textContent:s});return this.u(),this.u(),r.setAttribute("tabindex","-1"),r.setAttribute("aria-hidden","true"),c.addEventListener("click",()=>{r.click()}),r.addEventListener("change",()=>{c.style.maxWidth=`${c.offsetWidth}px`,r.files.length>0?c.textContent=r.files[0].name:c.textContent=s}),i(this,a,r,c),this}H(n={},i=()=>{}){return i(this,o(this,t,e).call(this,"textarea",{},n)),this}B(t,e,n=!1){const i=document.getElementById(t.replace(/^#/,""));i&&(i instanceof HTMLInputElement?i.value=e:n?i.textContent=e:i.innerHTML=e)}L(t,e){let n,i=!1,o=0,s=null,a=0,r=0,c=0,l=0;if(t=document.querySelector("#"==t?.[0]?t:"#"+t),e=document.querySelector("#"==e?.[0]?e:"#"+e),!t||!e)return void this.j(`Can not drag! ${t?"":"moveMe"} ${t||e?"":"and "}${e?"":"iMoveThings "}was not found!`);const h=()=>{if(i){const e=Math.abs(a-c),n=Math.abs(r-l);(e>.5||n>.5)&&(a=c,r=l,t.style.transform=`translate(${a}px, ${r}px)`,t.style.left="0px",t.style.top="0px",t.style.right=""),s=requestAnimationFrame(h)}};let m=null;const u=(u,d)=>{i=!0,m=t.getBoundingClientRect(),n=u-m.left,o=d-m.top;const p=window.getComputedStyle(t).transform;if(p&&"none"!==p){const t=new DOMMatrix(p);a=t.m41,r=t.m42}else a=m.left,r=m.top;c=a,l=r,document.body.style.userSelect="none",e.classList.add("dragging"),s&&cancelAnimationFrame(s),h()},d=()=>{i=!1,s&&(cancelAnimationFrame(s),s=null),document.body.style.userSelect="",e.classList.remove("dragging")};e.addEventListener("mousedown",function(t){t.preventDefault(),u(t.clientX,t.clientY)}),e.addEventListener("touchstart",function(t){const e=t?.touches?.[0];e&&(u(e.clientX,e.clientY),t.preventDefault())},{passive:!1}),document.addEventListener("mousemove",function(t){i&&m&&(c=t.clientX-n,l=t.clientY-o)},{passive:!0}),document.addEventListener("touchmove",function(t){if(i&&m){const e=t?.touches?.[0];if(!e)return;c=e.clientX-n,l=e.clientY-o,t.preventDefault()}},{passive:!1}),document.addEventListener("mouseup",d),document.addEventListener("touchend",d),document.addEventListener("touchcancel",d)}A(t){(0,console.info)(`${this.name}: ${t}`),this.B(this.i,"Status: "+t,!0)}j(t){(0,console.error)(`${this.name}: ${t}`),this.B(this.i,"Error: "+t,!0)}};function a(t,e){if(0===t)return e[0];let n="";const i=e.length;for(;t>0;)n=e[t%i]+n,t=Math.floor(t/i);return n}function r(t){let e="";for(let n=0;n<t.length;n++)e+=String.fromCharCode(t[n]);return btoa(e)}function c(t){const e=atob(t),n=new Uint8Array(e.length);for(let t=0;t<e.length;t++)n[t]=e.charCodeAt(t);return n}t=new WeakSet,e=function(t,e={},n={}){const i=document.createElement(t);this.o?(this.l?.appendChild(i),this.h.push(this.l),this.l=i):(this.o=i,this.l=i);for(const[t,n]of Object.entries(e))i[t]=n;for(const[t,e]of Object.entries(n))i[t]=e;return i};var l,h,m,u=class{constructor({displayName:t="My template",G:e=0,J:n="",url:i="",file:o=null,coords:s=null,F:a=null,R:r=1e3}={}){this.displayName=t,this.G=e,this.J=n,this.url=i,this.file=o,this.coords=s,this.F=a,this.R=r,this.Y=0}async q(){console.log("Template coordinates:",this.coords);const t=await createImageBitmap(this.file),e=t.width,n=t.height,i=e*n;console.log(`Template pixel analysis - Dimensions: ${e}×${n} = ${i.toLocaleString()} pixels`),this.Y=i;const o={},s={},a=new OffscreenCanvas(this.R,this.R),c=a.getContext("2d",{X:!0});for(let i=this.coords[3];i<n+this.coords[3];){const l=Math.min(this.R-i%this.R,n-(i-this.coords[3]));console.log(`Math.min(${this.R} - (${i} % ${this.R}), ${n} - (${i-this.coords[3]}))`);for(let n=this.coords[2];n<e+this.coords[2];){console.log(`Pixel X: ${n}\nPixel Y: ${i}`);const h=Math.min(this.R-n%this.R,e-(n-this.coords[2]));console.log(`Math.min(${this.R} - (${n} % ${this.R}), ${e} - (${n-this.coords[2]}))`),console.log(`Draw Size X: ${h}\nDraw Size Y: ${l}`);const m=3*h,u=3*l;a.width=m,a.height=u,console.log(`Draw X: ${h}\nDraw Y: ${l}\nCanvas Width: ${m}\nCanvas Height: ${u}`),c.imageSmoothingEnabled=!1,console.log(`Getting X ${n}-${n+h}\nGetting Y ${i}-${i+l}`),c.clearRect(0,0,m,u),c.drawImage(t,n-this.coords[2],i-this.coords[3],h,l,0,0,3*h,3*l);const d=c.getImageData(0,0,m,u);for(let t=0;t<u;t++)for(let e=0;e<m;e++)if(e%3!=1||t%3!=1){const n=4*(t*m+e);d.data[n+3]=0}console.log(`Shreaded pixels for ${n}, ${i}`,d),c.putImageData(d,0,0);const p=`${(this.coords[0]+Math.floor(n/1e3)).toString().padStart(4,"0")},${(this.coords[1]+Math.floor(i/1e3)).toString().padStart(4,"0")},${(n%1e3).toString().padStart(3,"0")},${(i%1e3).toString().padStart(3,"0")}`;o[p]=await createImageBitmap(a);const b=await a.convertToBlob(),f=await b.arrayBuffer(),w=Array.from(new Uint8Array(f));s[p]=r(w),console.log(o),n+=h}i+=l}return console.log("Template Tiles: ",o),console.log("Template Tiles Buffers: ",s),{_:o,U:s}}};l=new WeakSet,h=async function(){GM.setValue("bmTemplates",JSON.stringify(this.V))},m=async function(t){console.log("Parsing BlueMarble...");const e=t.templates;if(console.log(`BlueMarble length: ${Object.keys(e).length}`),Object.keys(e).length>0)for(const t in e){const n=t,i=e[t];if(console.log(n),e.hasOwnProperty(t)){const t=n.split(" "),e=Number(t?.[0]),o=t?.[1]||"0",s=i.name||`Template ${e||""}`,a=i.tiles,r={};for(const t in a)if(console.log(t),a.hasOwnProperty(t)){const e=c(a[t]),n=new Blob([e],{type:"image/png"}),i=await createImageBitmap(n);r[t]=i}const l=new u({displayName:s,G:e||this.W?.length||0,J:o||""});l.F=r,this.W.push(l),console.log(this.W),console.log("^^^ This ^^^")}}};var d=GM_info.script.name.toString(),p=GM_info.script.version.toString();!function(t){const e=document.createElement("script");e.setAttribute("bm-r",d),e.setAttribute("bm-o","color: cornflowerblue;"),e.textContent=`(${t})();`,document.documentElement?.appendChild(e),e.remove()}(()=>{const t=document.currentScript,e=t?.getAttribute("bm-r")||"Blue Marble",n=t?.getAttribute("bm-o")||"",i=new Map;window.addEventListener("message",t=>{const{source:o,endpoint:s,blobID:a,blobData:r,blink:c}=t.data,l=Date.now()-c;if(console.groupCollapsed(`%c${e}%c: ${i.size} Recieved IMAGE message about blob "${a}"`,n,""),console.log(`Blob fetch took %c${String(Math.floor(l/6e4)).padStart(2,"0")}:${String(Math.floor(l/1e3)%60).padStart(2,"0")}.${String(l%1e3).padStart(3,"0")}%c MM:SS.mmm`,n,""),console.log(i),console.groupEnd(),"blue-marble"==o&&a&&r&&!s){const t=i.get(a);"function"==typeof t?t(r):function(...t){(0,console.warn)(...t)}(`%c${e}%c: Attempted to retrieve a blob (%s) from queue, but the blobID was not a function! Skipping...`,n,"",a),i.delete(a)}});const o=window.fetch;window.fetch=async function(...t){const s=await o.apply(this,t),a=s.clone(),r=(t[0]instanceof Request?t[0]?.url:t[0])||"ignore",c=a.headers.get("content-type")||"";if(c.includes("application/json"))console.log(`%c${e}%c: Sending JSON message about endpoint "${r}"`,n,""),a.json().then(t=>{window.postMessage({source:"blue-marble",endpoint:r,jsonData:t},"*")}).catch(t=>{console.error(`%c${e}%c: Failed to parse JSON: `,n,"",t)});else if(c.includes("image/")&&!r.includes("openfreemap")&&!r.includes("maps")){const t=Date.now(),o=await a.blob();return console.log(`%c${e}%c: ${i.size} Sending IMAGE message about endpoint "${r}"`,n,""),new Promise(s=>{const c=crypto.randomUUID();i.set(c,t=>{s(new Response(t,{headers:a.headers,status:a.status,statusText:a.statusText})),console.log(`%c${e}%c: ${i.size} Processed blob "${c}"`,n,"")}),window.postMessage({source:"blue-marble",endpoint:r,blobID:c,blobData:o,blink:t})}).catch(o=>{const s=Date.now();console.error(`%c${e}%c: Failed to Promise blob!`,n,""),console.groupCollapsed(`%c${e}%c: Details of failed blob Promise:`,n,""),console.log(`Endpoint: ${r}\nThere are ${i.size} blobs processing...\nBlink: ${t.toLocaleString()}\nTime Since Blink: ${String(Math.floor(s/6e4)).padStart(2,"0")}:${String(Math.floor(s/1e3)%60).padStart(2,"0")}.${String(s%1e3).padStart(3,"0")} MM:SS.mmm`),console.error("Exception stack:",o),console.groupEnd()})}return s}});var b=GM_getResourceText("CSS-BM-File");GM_addStyle(b);var f=document.createElement("link");f.href="https://fonts.googleapis.com/css2?family=Roboto+Mono:ital,wght@0,100..700;1,100..700&display=swap",f.rel="preload",f.as="style",f.onload=function(){this.onload=null,this.rel="stylesheet"},document.head?.appendChild(f),new class{constructor(){this.Z=null,this.K=null,this.tt="#bm-5"}et(t){return this.K=t,this.Z=new MutationObserver(t=>{for(const e of t)for(const t of e.addedNodes)t instanceof HTMLElement&&t.matches?.(this.tt)}),this}nt(){return this.Z}observe(t,e=!1,n=!1){t.observe(this.K,{childList:e,subtree:n})}};var w=new s(d,p),g=(new s(d,p),new class{constructor(t,e,n){i(this,l),this.name=t,this.version=e,this.o=n,this.it="1.0.0",this.ot=null,this.st="!#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwxyz{|}~",this.R=1e3,this.rt=3,this.ct=null,this.lt=null,this.ht="bm-p",this.ut="div#map canvas.maplibregl-canvas",this.dt=null,this.bt="",this.W=[],this.V=null,this.ft=!0}wt(){if(document.body.contains(this.ct))return this.ct;document.getElementById(this.ht)?.remove();const t=document.querySelector(this.ut),e=document.createElement("canvas");return e.id=this.ht,e.className="maplibregl-canvas",e.style.position="absolute",e.style.top="0",e.style.left="0",e.style.height=t?.clientHeight*(window.devicePixelRatio||1)+"px",e.style.width=t?.clientWidth*(window.devicePixelRatio||1)+"px",e.height=t?.clientHeight*(window.devicePixelRatio||1),e.width=t?.clientWidth*(window.devicePixelRatio||1),e.style.zIndex="8999",e.style.pointerEvents="none",t?.parentElement?.appendChild(e),this.ct=e,window.addEventListener("move",this.gt),window.addEventListener("zoom",this.$t),window.addEventListener("resize",this.vt),this.ct}async xt(){return{whoami:this.name.replace(" ",""),scriptVersion:this.version,schemaVersion:this.it,templates:{}}}async yt(t,e,n){this.V||(this.V=await this.xt(),console.log("Creating JSON...")),this.o.A(`Creating template at ${n.join(", ")}...`);const i=new u({displayName:e,G:0,J:a(this.ot||0,this.st),file:t,coords:n}),{_:s,U:r}=await i.q(this.R);i.F=s,this.V.templates[`${i.G} ${i.J}`]={name:i.displayName,coords:n.join(", "),enabled:!0,tiles:r},this.W=[],this.W.push(i);const c=(new Intl.NumberFormat).format(i.Y);this.o.A(`Template created at ${n.join(", ")}! Total pixels: ${c}`),console.log(Object.keys(this.V.templates).length),console.log(this.V),console.log(this.W),console.log(JSON.stringify(this.V)),await o(this,l,h).call(this)}Mt(){}async St(){this.V||(this.V=await this.xt(),console.log("Creating JSON..."))}async Tt(t,e){if(!this.ft)return t;const n=this.R*this.rt;e=e[0].toString().padStart(4,"0")+","+e[1].toString().padStart(4,"0"),console.log(`Searching for templates in tile: "${e}"`);const i=this.W;console.log(i),i.sort((t,e)=>t.G-e.G),console.log(i);const o=i.map(t=>{const n=Object.keys(t.F).filter(t=>t.startsWith(e));if(0===n.length)return null;const i=n.map(e=>{const n=e.split(",");return{Dt:t.F[e],Ct:[n[0],n[1]],It:[n[2],n[3]]}});return i?.[0]}).filter(Boolean);console.log(o);const s=o?.length||0;if(console.log(`templateCount = ${s}`),s>0){const t=i.filter(t=>Object.keys(t.F).filter(t=>t.startsWith(e)).length>0).reduce((t,e)=>t+(e.Y||0),0),n=(new Intl.NumberFormat).format(t);this.o.A(`Displaying ${s} template${1==s?"":"s"}.\nTotal pixels: ${n}`)}else this.o.A(`Displaying ${s} templates.`);const a=await createImageBitmap(t),r=new OffscreenCanvas(n,n),c=r.getContext("2d");c.imageSmoothingEnabled=!1,c.beginPath(),c.rect(0,0,n,n),c.clip(),c.clearRect(0,0,n,n),c.drawImage(a,0,0,n,n);for(const t of o)console.log("Template:"),console.log(t),c.drawImage(t.Dt,Number(t.It[0])*this.rt,Number(t.It[1])*this.rt);return await r.convertToBlob({type:"image/png"})}kt(t){console.log("Importing JSON..."),console.log(t),"BlueMarble"==t?.whoami&&o(this,l,m).call(this,t)}Nt(t){this.ft=t}}(d,p,w)),$=new class{constructor(t){this.Bt=t,this.Ot=!1,this.Pt=[],this.zt=[]}Et(t){window.addEventListener("message",async e=>{const n=e.data,i=n.jsonData;if(!n||"blue-marble"!==n.source)return;if(!n.endpoint)return;const o=n.endpoint?.split("?")[0].split("/").filter(t=>t&&isNaN(Number(t))).filter(t=>t&&!t.includes(".")).pop();switch(console.log('%cBlue Marble%c: Recieved message about "%s"',"color: cornflowerblue;","",o),o){case"me":if(i.status&&"2"!=i.status?.toString()[0])return void t.j("You are not logged in!\nCould not fetch userdata.");const e=Math.ceil(Math.pow(Math.floor(i.level)*Math.pow(30,.65),1/.65)-i.pixelsPainted);console.log(i.id),(i.id||0===i.id)&&console.log(a(i.id,"!#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwxyz{|}~")),this.Bt.ot=i.id,t.B("bm-h",`Username: <b>${function(t){const e=document.createElement("div");return e.textContent=t,e.innerHTML}(i.name)}</b>`),t.B("bm-c",`Droplets: <b>${(new Intl.NumberFormat).format(i.droplets)}</b>`),t.B("bm-6",`Next level in <b>${(new Intl.NumberFormat).format(e)}</b> pixel${1==e?"":"s"}`);break;case"pixel":const o=n.endpoint.split("?")[0].split("/").filter(t=>t&&!isNaN(Number(t))),c=new URLSearchParams(n.endpoint.split("?")[1]),l=[c.get("x"),c.get("y")];if(this.Pt.length&&(!o.length||!l.length))return void t.j("Coordinates are malformed!\nDid you try clicking the canvas first?");this.Pt=[...o,...l];const h=(s=o,r=l,[parseInt(s[0])%4*1e3+parseInt(r[0]),parseInt(s[1])%4*1e3+parseInt(r[1])]),m=document.querySelectorAll("span");for(const t of m)if(t.textContent.trim().includes(`${h[0]}, ${h[1]}`)){let e=document.querySelector("#bm-5");const n=`(Tl X: ${o[0]}, Tl Y: ${o[1]}, Px X: ${l[0]}, Px Y: ${l[1]})`;e?e.textContent=n:(e=document.createElement("span"),e.id="bm-5",e.textContent=n,e.style="margin-left: calc(var(--spacing)*3); font-size: small;",t.parentNode.parentNode.parentNode.insertAdjacentElement("afterend",e))}break;case"tiles":let u=n.endpoint.split("/");u=[parseInt(u[u.length-2]),parseInt(u[u.length-1].replace(".png",""))];const d=n.blobID,p=n.blobData,b=await this.Bt.Tt(p,u);window.postMessage({source:"blue-marble",blobID:d,blobData:b,blink:n.blink});break;case"robots":this.Ot="false"==i.userscript?.toString().toLowerCase();break}var s,r})}}(g);w.m($);var v=JSON.parse(GM_getValue("bmTemplates","{}"));console.log(v),g.kt(v),function(){let t=!1;w.$({id:"bm-n",style:"top: 10px; right: 75px;"}).$({id:"bm-7"}).$({id:"bm-i"}).u().S({alt:"Blue Marble Icon - Click to minimize/maximize",src:"https://raw.githubusercontent.com/SwingTheVine/Wplace-BlueMarble/main/dist/assets/Favicon.png",style:"cursor: pointer;"},(e,n)=>{n.addEventListener("click",()=>{t=!t;const i=document.querySelector("#bm-n"),o=document.querySelector("#bm-7"),s=document.querySelector("#bm-i"),a=document.querySelector("#bm-8"),r=document.querySelector("#bm-d"),c=document.querySelector("#bm-e"),l=document.querySelector("#bm-f"),h=document.querySelector("#bm-9"),m=document.querySelectorAll("#bm-8 input");t||(i.style.width="auto",i.style.maxWidth="300px",i.style.minWidth="200px",i.style.padding="10px"),["#bm-n h1","#bm-4","#bm-n hr","#bm-3 > *:not(#bm-8)","#bm-2","#bm-1",`#${e.i}`].forEach(e=>{document.querySelectorAll(e).forEach(e=>{e.style.display=t?"none":""})}),t?(a&&(a.style.display="none"),r&&(r.style.display="none"),c&&(c.style.display="none"),l&&(l.style.display="none"),h&&(h.style.display="none"),m.forEach(t=>{t.style.display="none"}),i.style.width="60px",i.style.height="76px",i.style.maxWidth="60px",i.style.minWidth="60px",i.style.padding="8px",n.style.marginLeft="3px",o.style.textAlign="center",o.style.margin="0",o.style.marginBottom="0",s&&(s.style.display="",s.style.marginBottom="0.25em")):(a&&(a.style.display="",a.style.flexDirection="",a.style.justifyContent="",a.style.alignItems="",a.style.gap="",a.style.textAlign="",a.style.margin=""),r&&(r.style.display=""),c&&(c.style.display="",c.style.marginTop=""),l&&(l.style.display="",l.style.marginTop=""),h&&(h.style.display="",h.style.marginTop=""),m.forEach(t=>{t.style.display=""}),n.style.marginLeft="",i.style.padding="10px",o.style.textAlign="",o.style.margin="",o.style.marginBottom="",s&&(s.style.marginBottom="0.5em"),i.style.width="",i.style.height=""),n.alt=t?"Blue Marble Icon - Minimized (Click to maximize)":"Blue Marble Icon - Maximized (Click to minimize)"})}).u().T(1,{textContent:d}).u().u().D().u().$({id:"bm-4"}).v({id:"bm-h",textContent:"Username:"}).u().v({id:"bm-c",textContent:"Droplets:"}).u().v({id:"bm-6",textContent:"Next level in..."}).u().u().D().u().$({id:"bm-3"}).$({id:"bm-8"}).k({id:"bm-d",className:"bm-q",style:"margin-top: 0;",innerHTML:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 4 6"><circle cx="2" cy="2" r="2"></circle><path d="M2 6 L3.7 3 L0.3 3 Z"></path><circle cx="2" cy="2" r="0.7" fill="white"></circle></svg></svg>'},(t,e)=>{e.onclick=()=>{const e=t.t?.Pt;e?.[0]?(t.B("bm-j",e?.[0]||""),t.B("bm-k",e?.[1]||""),t.B("bm-l",e?.[2]||""),t.B("bm-m",e?.[3]||"")):t.j("Coordinates are malformed! Did you try clicking on the canvas first?")}}).u().O({type:"number",id:"bm-j",placeholder:"Tl X",min:0,max:2047,step:1,required:!0}).u().O({type:"number",id:"bm-k",placeholder:"Tl Y",min:0,max:2047,step:1,required:!0}).u().O({type:"number",id:"bm-l",placeholder:"Px X",min:0,max:2047,step:1,required:!0}).u().O({type:"number",id:"bm-m",placeholder:"Px Y",min:0,max:2047,step:1,required:!0}).u().u().P({id:"bm-2",textContent:"Upload Template",accept:"image/png, image/jpeg, image/webp, image/bmp, image/gif"}).u().$({id:"bm-0"}).k({id:"bm-f",textContent:"Enable"},(t,e)=>{e.onclick=()=>{t.t?.Bt?.Nt(!0),t.A("Enabled templates!")}}).u().k({id:"bm-e",textContent:"Create"},(t,e)=>{e.onclick=()=>{const e=document.querySelector("#bm-2"),n=document.querySelector("#bm-j");if(!n.checkValidity())return n.reportValidity(),void t.j("Coordinates are malformed! Did you try clicking on the canvas first?");const i=document.querySelector("#bm-k");if(!i.checkValidity())return i.reportValidity(),void t.j("Coordinates are malformed! Did you try clicking on the canvas first?");const o=document.querySelector("#bm-l");if(!o.checkValidity())return o.reportValidity(),void t.j("Coordinates are malformed! Did you try clicking on the canvas first?");const s=document.querySelector("#bm-m");if(!s.checkValidity())return s.reportValidity(),void t.j("Coordinates are malformed! Did you try clicking on the canvas first?");e?.files[0]?(g.yt(e.files[0],e.files[0]?.name.replace(/\.[^/.]+$/,""),[Number(n.value),Number(i.value),Number(o.value),Number(s.value)]),t.A("Drew to canvas!")):t.j("No file selected!")}}).u().k({id:"bm-9",textContent:"Disable"},(t,e)=>{e.onclick=()=>{t.t?.Bt?.Nt(!1),t.A("Disabled templates!")}}).u().u().H({id:w.i,placeholder:`Status: Sleeping...\nVersion: ${p}`,readOnly:!0}).u().$({id:"bm-1"}).$().k({id:"bm-a",className:"bm-q",innerHTML:"🎨",title:"Template Color Converter"},(t,e)=>{e.addEventListener("click",()=>{window.open("https://pepoafonso.github.io/color_converter_wplace/","_blank","noopener noreferrer")})}).u().u().M({textContent:"Made by SwingTheVine",style:"margin-top: auto;"}).u().u().u().p(document.body)}(),w.L("#bm-n","#bm-i"),$.Et(w),new MutationObserver((t,e)=>{const n=document.querySelector("#color-1");if(!n)return;let i=document.querySelector("#bm-g");if(!i){i=document.createElement("button"),i.id="bm-g",i.textContent="Move ↑",i.className="btn btn-soft",i.onclick=function(){const t=this.parentNode.parentNode.parentNode.parentNode,e="Move ↑"==this.textContent;t.parentNode.className=t.parentNode.className.replace(e?"bottom":"top",e?"top":"bottom"),t.style.borderTopLeftRadius=e?"0px":"var(--radius-box)",t.style.borderTopRightRadius=e?"0px":"var(--radius-box)",t.style.borderBottomLeftRadius=e?"var(--radius-box)":"0px",t.style.borderBottomRightRadius=e?"var(--radius-box)":"0px",this.textContent=e?"Move ↓":"Move ↑"};const t=n.parentNode.parentNode.parentNode.parentNode.querySelector("h2");t.parentNode?.appendChild(i)}}).observe(document.body,{childList:!0,subtree:!0}),function(...t){(0,console.log)(...t)}(`%c${d}%c (${p}) userscript has loaded!`,"color: cornflowerblue;","")})(); |