diff --git a/.github/workflows/pr-branch-check.yml b/.github/workflows/pr-branch-check.yml
index 84fedf5..9ea0d64 100644
--- a/.github/workflows/pr-branch-check.yml
+++ b/.github/workflows/pr-branch-check.yml
@@ -2,7 +2,6 @@ name: Enforce allowed branches for PRs to main
permissions:
contents: read
-
on:
pull_request:
branches:
diff --git a/dist/BlueMarble.user.js b/dist/BlueMarble.user.js
index 00b86c3..667024a 100644
--- a/dist/BlueMarble.user.js
+++ b/dist/BlueMarble.user.js
@@ -23,4 +23,4 @@
// Wplace --> https://wplace.live
// License --> https://www.mozilla.org/en-US/MPL/2.0/
-(()=>{var e,t,n=e=>{throw TypeError(e)},i=(e,t,i)=>t.has(e)?n("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,i),o=(e,t,i)=>(((e,t)=>{t.has(e)||n("Cannot access private method")})(e,t),i),s=class{constructor(t,n){i(this,e),this.name=t,this.version=n,this.t=null,this.i="bm-o",this.o=null,this.l=null,this.m=[]}u(e){this.t=e}h(){return this.m.length>0&&(this.l=this.m.pop()),this}p(e){e?.appendChild(this.o),this.o=null,this.l=null,this.m=[]}$(n={},i=()=>{}){return i(this,o(this,e,t).call(this,"div",{},n)),this}v(n={},i=()=>{}){return i(this,o(this,e,t).call(this,"p",{},n)),this}S(n={},i=()=>{}){return i(this,o(this,e,t).call(this,"small",{},n)),this}M(n={},i=()=>{}){return i(this,o(this,e,t).call(this,"img",{},n)),this}O(n,i={},s=()=>{}){return s(this,o(this,e,t).call(this,"h"+n,{},i)),this}T(n={},i=()=>{}){return i(this,o(this,e,t).call(this,"hr",{},n)),this}D(n={},i=()=>{}){return i(this,o(this,e,t).call(this,"br",{},n)),this}k(n={},i=()=>{}){const s=o(this,e,t).call(this,"label",{textContent:n.textContent??""});delete n.textContent;const r=o(this,e,t).call(this,"input",{type:"checkbox"},n);return s.insertBefore(r,s.firstChild),this.h(),i(this,s,r),this}C(n={},i=()=>{}){return i(this,o(this,e,t).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 r={textContent:"?",className:"bm-D",onclick:()=>{this.B(this.i,s)}};return i(this,o(this,e,t).call(this,"button",r,n)),this}I(n={},i=()=>{}){return i(this,o(this,e,t).call(this,"input",{},n)),this}L(n={},i=()=>{}){const s=n.textContent??"";delete n.textContent;const r=o(this,e,t).call(this,"div"),a=o(this,e,t).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.h();const l=o(this,e,t).call(this,"button",{textContent:s});return this.h(),this.h(),a.setAttribute("tabindex","-1"),a.setAttribute("aria-hidden","true"),l.addEventListener("click",()=>{a.click()}),a.addEventListener("change",()=>{l.style.maxWidth=`${l.offsetWidth}px`,a.files.length>0?l.textContent=a.files[0].name:l.textContent=s}),i(this,r,a,l),this}G(n={},i=()=>{}){return i(this,o(this,e,t).call(this,"textarea",{},n)),this}B(e,t,n=!1){const i=document.getElementById(e.replace(/^#/,""));i&&(i instanceof HTMLInputElement?i.value=t:n?i.textContent=t:i.innerHTML=t)}P(e,t){let n,i=!1,o=0,s=null,r=0,a=0,l=0,c=0;if(e=document.querySelector("#"==e?.[0]?e:"#"+e),t=document.querySelector("#"==t?.[0]?t:"#"+t),!e||!t)return void this.W(`Can not drag! ${e?"":"moveMe"} ${e||t?"":"and "}${t?"":"iMoveThings "}was not found!`);const m=()=>{if(i){const t=Math.abs(r-l),n=Math.abs(a-c);(t>.5||n>.5)&&(r=l,a=c,e.style.transform=`translate(${r}px, ${a}px)`,e.style.left="0px",e.style.top="0px",e.style.right=""),s=requestAnimationFrame(m)}};let u=null;const d=(d,h)=>{i=!0,u=e.getBoundingClientRect(),n=d-u.left,o=h-u.top;const b=window.getComputedStyle(e).transform;if(b&&"none"!==b){const e=new DOMMatrix(b);r=e.m41,a=e.m42}else r=u.left,a=u.top;l=r,c=a,document.body.style.userSelect="none",t.classList.add("dragging"),s&&cancelAnimationFrame(s),m()},h=()=>{i=!1,s&&(cancelAnimationFrame(s),s=null),document.body.style.userSelect="",t.classList.remove("dragging")};t.addEventListener("mousedown",function(e){e.preventDefault(),d(e.clientX,e.clientY)}),t.addEventListener("touchstart",function(e){const t=e?.touches?.[0];t&&(d(t.clientX,t.clientY),e.preventDefault())},{passive:!1}),document.addEventListener("mousemove",function(e){i&&u&&(l=e.clientX-n,c=e.clientY-o)},{passive:!0}),document.addEventListener("touchmove",function(e){if(i&&u){const t=e?.touches?.[0];if(!t)return;l=t.clientX-n,c=t.clientY-o,e.preventDefault()}},{passive:!1}),document.addEventListener("mouseup",h),document.addEventListener("touchend",h),document.addEventListener("touchcancel",h)}F(e){(0,console.info)(`${this.name}: ${e}`),this.B(this.i,"Status: "+e,!0)}W(e){(0,console.error)(`${this.name}: ${e}`),this.B(this.i,"Error: "+e,!0)}};function r(...e){(0,console.error)(...e)}function a(e,t){if(0===e)return t[0];let n="";const i=t.length;for(;e>0;)n=t[e%i]+n,e=Math.floor(e/i);return n}function l(e){let t="";for(let n=0;n"transparent"!==(e?.name||"").toLowerCase()&&Array.isArray(e?.rgb)).map(e=>`${e.rgb[0]},${e.rgb[1]},${e.rgb[2]}`));const c="222,250,206";this.H.add(c);const m="other";this.H.add(m),this.K=new Map(l.filter(e=>Array.isArray(e?.rgb)).map(e=>[`${e.rgb[0]},${e.rgb[1]},${e.rgb[2]}`,{id:e.id,premium:!!e.premium,name:e.name}]));try{const e=l.find(e=>"transparent"===(e?.name||"").toLowerCase());e&&Array.isArray(e.rgb)&&this.K.set(c,{id:e.id,premium:!!e.premium,name:e.name})}catch(e){}try{this.K.set(m,{id:"other",premium:!1,name:"Other"})}catch(e){}console.log("Allowed colors for template:",this.H)}async Z(){console.log("Template coordinates:",this.coords);const e=await createImageBitmap(this.file),t=e.width,n=e.height,i=t*n;console.log(`Template pixel analysis - Dimensions: ${t}×${n} = ${i.toLocaleString()} pixels`),this.R=i;try{const i=new OffscreenCanvas(t,n).getContext("2d",{ee:!0});i.imageSmoothingEnabled=!1,i.clearRect(0,0,t,n),i.drawImage(e,0,0);const o=i.getImageData(0,0,t,n).data;let s=0,r=0;const a=new Map;for(let e=0;e0){for(const e in t){const n=e,i=t[e];if(console.log(n),t.hasOwnProperty(e)){const e=n.split(" "),o=Number(e?.[0]),s=e?.[1]||"0",r=i.name||`Template ${o||""}`,a=i.tiles,l={};let m=0;const u=new Map;for(const e in a)if(console.log(e),a.hasOwnProperty(e)){const t=c(a[e]),n=new Blob([t],{type:"image/png"}),i=await createImageBitmap(n);l[e]=i;try{const e=i.width,t=i.height,n=new OffscreenCanvas(e,t).getContext("2d",{ee:!0});n.imageSmoothingEnabled=!1,n.clearRect(0,0,e,t),n.drawImage(i,0,0);const o=n.getImageData(0,0,e,t).data;for(let n=0;n{d.U?.add(e.split(",").slice(0,2).join(","))})}catch(e){}try{const e=t?.[n]?.palette;if(e)for(const[t,n]of Object.entries(e))d.Y[t]?d.Y[t].enabled=!!n?.enabled:d.Y[t]={count:n?.count||0,enabled:!!n?.enabled}}catch(e){}d.V=n,this.se.push(d),console.log(this.se),console.log("^^^ This ^^^")}}try{const e=document.querySelector("#bm-9");e&&(e.style.display=""),window.postMessage({source:"blue-marble",re:"bm-b"},"*")}catch(e){}}},h=new WeakSet,b=async function(e=navigator.userAgent){return(e=e||"").includes("OPR/")||e.includes("Opera")?"Opera":e.includes("Edg/")?"Edge":e.includes("Vivaldi")?"Vivaldi":e.includes("YaBrowser")?"Yandex":e.includes("Kiwi")?"Kiwi":e.includes("Brave")?"Brave":e.includes("Firefox/")?"Firefox":e.includes("Chrome/")?"Chrome":e.includes("Safari/")?"Safari":navigator.brave&&"function"==typeof navigator.brave.isBrave&&await navigator.brave.isBrave()?"Brave":"Unknown"},p=function(e=navigator.userAgent){return/Windows NT 11/i.test(e=e||"")?"Windows 11":/Windows NT 10/i.test(e)?"Windows 10":/Windows NT 6\.3/i.test(e)?"Windows 8.1":/Windows NT 6\.2/i.test(e)?"Windows 8":/Windows NT 6\.1/i.test(e)?"Windows 7":/Windows NT 6\.0/i.test(e)?"Windows Vista":/Windows NT 5\.1|Windows XP/i.test(e)?"Windows XP":/Mac OS X 10[_\.]15/i.test(e)?"macOS Catalina":/Mac OS X 10[_\.]14/i.test(e)?"macOS Mojave":/Mac OS X 10[_\.]13/i.test(e)?"macOS High Sierra":/Mac OS X 10[_\.]12/i.test(e)?"macOS Sierra":/Mac OS X 10[_\.]11/i.test(e)?"OS X El Capitan":/Mac OS X 10[_\.]10/i.test(e)?"OS X Yosemite":/Mac OS X 10[_\.]/i.test(e)?"macOS":/Android/i.test(e)?"Android":/iPhone|iPad|iPod/i.test(e)?"iOS":/Linux/i.test(e)?"Linux":"Unknown"};var w=GM_info.script.name.toString(),y=GM_info.script.version.toString();!function(e){const t=document.createElement("script");t.setAttribute("bm-E",w),t.setAttribute("bm-B","color: cornflowerblue;"),t.textContent=`(${e})();`,document.documentElement?.appendChild(t),t.remove()}(()=>{const e=document.currentScript,t=e?.getAttribute("bm-E")||"Blue Marble",n=e?.getAttribute("bm-B")||"",i=new Map;window.addEventListener("message",e=>{const{source:o,endpoint:s,blobID:r,blobData:a,blink:l}=e.data,c=Date.now()-l;if(console.groupCollapsed(`%c${t}%c: ${i.size} Recieved IMAGE message about blob "${r}"`,n,""),console.log(`Blob fetch took %c${String(Math.floor(c/6e4)).padStart(2,"0")}:${String(Math.floor(c/1e3)%60).padStart(2,"0")}.${String(c%1e3).padStart(3,"0")}%c MM:SS.mmm`,n,""),console.log(i),console.groupEnd(),"blue-marble"==o&&r&&a&&!s){const e=i.get(r);"function"==typeof e?e(a):function(...e){(0,console.warn)(...e)}(`%c${t}%c: Attempted to retrieve a blob (%s) from queue, but the blobID was not a function! Skipping...`,n,"",r),i.delete(r)}});const o=window.fetch;window.fetch=async function(...e){const s=await o.apply(this,e),r=s.clone(),a=(e[0]instanceof Request?e[0]?.url:e[0])||"ignore",l=r.headers.get("content-type")||"";if(l.includes("application/json"))console.log(`%c${t}%c: Sending JSON message about endpoint "${a}"`,n,""),r.json().then(e=>{window.postMessage({source:"blue-marble",endpoint:a,jsonData:e},"*")}).catch(e=>{console.error(`%c${t}%c: Failed to parse JSON: `,n,"",e)});else if(l.includes("image/")&&!a.includes("openfreemap")&&!a.includes("maps")){const e=Date.now(),o=await r.blob();return console.log(`%c${t}%c: ${i.size} Sending IMAGE message about endpoint "${a}"`,n,""),new Promise(s=>{const l=crypto.randomUUID();i.set(l,e=>{s(new Response(e,{headers:r.headers,status:r.status,statusText:r.statusText})),console.log(`%c${t}%c: ${i.size} Processed blob "${l}"`,n,"")}),window.postMessage({source:"blue-marble",endpoint:a,blobID:l,blobData:o,blink:e})}).catch(o=>{const s=Date.now();console.error(`%c${t}%c: Failed to Promise blob!`,n,""),console.groupCollapsed(`%c${t}%c: Details of failed blob Promise:`,n,""),console.log(`Endpoint: ${a}\nThere are ${i.size} blobs processing...\nBlink: ${e.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 $=GM_getResourceText("CSS-BM-File");GM_addStyle($);var v=document.createElement("link");v.href="https://fonts.googleapis.com/css2?family=Roboto+Mono:ital,wght@0,100..700;1,100..700&display=swap",v.rel="preload",v.as="style",v.onload=function(){this.onload=null,this.rel="stylesheet"},document.head?.appendChild(v),new class{constructor(){this.ae=null,this.le=null,this.ce="#bm-h"}me(e){return this.le=e,this.ae=new MutationObserver(e=>{for(const t of e)for(const e of t.addedNodes)e instanceof HTMLElement&&e.matches?.(this.ce)}),this}ue(){return this.ae}observe(e,t=!1,n=!1){e.observe(this.le,{childList:t,subtree:n})}};var x=new s(w,y),S=(new s(w,y),new class{constructor(e,t,n){i(this,m),this.name=e,this.version=t,this.o=n,this.de="1.0.0",this.he=null,this.be="!#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwxyz{|}~",this.A=1e3,this.oe=3,this.pe=null,this.ge=null,this.fe="bm-C",this.we="div#map canvas.maplibregl-canvas",this.ye=null,this.$e="",this.se=[],this.ie=null,this.ve=!0,this.xe=new Map}Se(){if(document.body.contains(this.pe))return this.pe;document.getElementById(this.fe)?.remove();const e=document.querySelector(this.we),t=document.createElement("canvas");return t.id=this.fe,t.className="maplibregl-canvas",t.style.position="absolute",t.style.top="0",t.style.left="0",t.style.height=e?.clientHeight*(window.devicePixelRatio||1)+"px",t.style.width=e?.clientWidth*(window.devicePixelRatio||1)+"px",t.height=e?.clientHeight*(window.devicePixelRatio||1),t.width=e?.clientWidth*(window.devicePixelRatio||1),t.style.zIndex="8999",t.style.pointerEvents="none",e?.parentElement?.appendChild(t),this.pe=t,window.addEventListener("move",this.Me),window.addEventListener("zoom",this.Oe),window.addEventListener("resize",this.Te),this.pe}async De(){return{whoami:this.name.replace(" ",""),scriptVersion:this.version,schemaVersion:this.de,templates:{}}}async ke(e,t,n){this.ie||(this.ie=await this.De(),console.log("Creating JSON...")),this.o.F(`Creating template at ${n.join(", ")}...`);const i=new f({displayName:t,_:0,J:a(this.he||0,this.be),file:e,coords:n}),{te:s,ne:r}=await i.Z(this.A);i.j=s;const l=`${i._} ${i.J}`;i.V=l,this.ie.templates[l]={name:i.displayName,coords:n.join(", "),enabled:!0,tiles:r,palette:i.Y},this.se=[],this.se.push(i);const c=(new Intl.NumberFormat).format(i.R);this.o.F(`Template created at ${n.join(", ")}! Total pixels: ${c}`);try{const e=document.querySelector("#bm-9");e&&(e.style.display=""),window.postMessage({source:"blue-marble",re:"bm-b"},"*")}catch(e){}console.log(Object.keys(this.ie.templates).length),console.log(this.ie),console.log(this.se),console.log(JSON.stringify(this.ie)),await o(this,m,u).call(this)}Ce(){}async Ne(){this.ie||(this.ie=await this.De(),console.log("Creating JSON..."))}async Be(e,t){if(!this.ve)return e;const n=this.A*this.oe;t=t[0].toString().padStart(4,"0")+","+t[1].toString().padStart(4,"0"),console.log(`Searching for templates in tile: "${t}"`);const i=this.se;if(console.log(i),i.sort((e,t)=>e._-t._),console.log(i),!i.some(e=>!!e?.j&&(e.U&&e.U.size>0?e.U.has(t):Object.keys(e.j).some(e=>e.startsWith(t)))))return e;const o=i.map(e=>{const n=Object.keys(e.j).filter(e=>e.startsWith(t));if(0===n.length)return null;const i=n.map(t=>{const n=t.split(",");return{Ie:e.j[t],Le:[n[0],n[1]],Ge:[n[2],n[3]]}});return i?.[0]}).filter(Boolean);console.log(o);const s=o?.length||0;console.log(`templateCount = ${s}`);let r=0,a=0,l=0;const c=await createImageBitmap(e),m=new OffscreenCanvas(n,n),u=m.getContext("2d");u.imageSmoothingEnabled=!1,u.beginPath(),u.rect(0,0,n,n),u.clip(),u.clearRect(0,0,n,n),u.drawImage(c,0,0,n,n);let d=null;try{d=u.getImageData(0,0,n,n).data}catch(e){}for(const e of o){if(console.log("Template:"),console.log(e),d)try{const t=e.Ie.width,i=e.Ie.height,o=new OffscreenCanvas(t,i).getContext("2d",{ee:!0});o.imageSmoothingEnabled=!1,o.clearRect(0,0,t,i),o.drawImage(e.Ie,0,0);const s=o.getImageData(0,0,t,i).data,c=Number(e.Ge[0])*this.oe,m=Number(e.Ge[1])*this.oe;for(let e=0;e=n||u>=n)continue;const h=4*(e*t+i),b=s[h],p=s[h+1],g=s[h+2];if(s[h+3]<64){try{const e=this.se?.[0],t=4*(u*n+o),i=d[t],s=d[t+1],r=d[t+2],l=d[t+3],c=e.H.has(`${i},${s},${r}`)?`${i},${s},${r}`:"other",m=!!e?.H&&e.H.has(c);l>=64&&m&&a++}catch(e){}continue}l++;const f=4*(u*n+o),w=d[f],y=d[f+1],$=d[f+2];d[f+3]<64||(w===b&&y===p&&$===g?r++:a++)}}catch(e){console.warn("Failed to compute per-tile painted/wrong stats:",e)}try{const t=this.se?.[0],n=t?.Y||{};if(Object.values(n).some(e=>!1===e?.enabled)){console.log("Applying color filter...");const i=e.Ie.width,o=e.Ie.height,s=new OffscreenCanvas(i,o),r=s.getContext("2d",{ee:!0});r.imageSmoothingEnabled=!1,r.clearRect(0,0,i,o),r.drawImage(e.Ie,0,0);const a=r.getImageData(0,0,i,o),l=a.data;for(let e=0;e0){const e=t;this.xe.set(e,{Pe:r,required:l,We:a});let n=0,i=0,o=0;for(const e of this.xe.values())n+=e.Pe||0,i+=e.required||0,o+=e.We||0;const c=this.se.reduce((e,t)=>e+(t.X||t.R||0),0),m=c>0?c:i,u=(new Intl.NumberFormat).format(n),d=(new Intl.NumberFormat).format(m),h=(new Intl.NumberFormat).format(m-n);this.o.F(`Displaying ${s} template${1==s?"":"s"}.\nPainted ${u} / ${d} • Wrong ${h}`)}else this.o.F(`Displaying ${s} templates.`);return await m.convertToBlob({type:"image/png"})}Fe(e){console.log("Importing JSON..."),console.log(e),"BlueMarble"==e?.whoami&&o(this,m,d).call(this,e)}_e(e){this.ve=e}}(w,y,x)),M=new class{constructor(e){i(this,h),this.Ee=e,this.Je=!1,this.je=[],this.Ae=[]}Re(e){window.addEventListener("message",async t=>{const n=t.data,i=n.jsonData;if(!n||"blue-marble"!==n.source)return;if(!n.endpoint)return;const o=n.endpoint?.split("?")[0].split("/").filter(e=>e&&isNaN(Number(e))).filter(e=>e&&!e.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 e.W("You are not logged in!\nCould not fetch userdata.");const t=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.Ee.he=i.id,e.B("bm-u",`Username: ${function(e){const t=document.createElement("div");return t.textContent=e,t.innerHTML}(i.name)}`),e.B("bm-p",`Droplets: ${(new Intl.NumberFormat).format(i.droplets)}`),e.B("bm-i",`Next level in ${(new Intl.NumberFormat).format(t)} pixel${1==t?"":"s"}`);break;case"pixel":const o=n.endpoint.split("?")[0].split("/").filter(e=>e&&!isNaN(Number(e))),l=new URLSearchParams(n.endpoint.split("?")[1]),c=[l.get("x"),l.get("y")];if(this.je.length&&(!o.length||!c.length))return void e.W("Coordinates are malformed!\nDid you try clicking the canvas first?");this.je=[...o,...c];const m=(s=o,r=c,[parseInt(s[0])%4*1e3+parseInt(r[0]),parseInt(s[1])%4*1e3+parseInt(r[1])]),u=document.querySelectorAll("span");for(const e of u)if(e.textContent.trim().includes(`${m[0]}, ${m[1]}`)){let t=document.querySelector("#bm-h");const n=`(Tl X: ${o[0]}, Tl Y: ${o[1]}, Px X: ${c[0]}, Px Y: ${c[1]})`;t?t.textContent=n:(t=document.createElement("span"),t.id="bm-h",t.textContent=n,t.style="margin-left: calc(var(--spacing)*3); font-size: small;",e.parentNode.parentNode.parentNode.insertAdjacentElement("afterend",t))}break;case"tiles":let d=n.endpoint.split("/");d=[parseInt(d[d.length-2]),parseInt(d[d.length-1].replace(".png",""))];const h=n.blobID,b=n.blobData,p=await this.Ee.Be(b,d);window.postMessage({source:"blue-marble",blobID:h,blobData:p,blink:n.blink});break;case"robots":this.Je="false"==i.userscript?.toString().toLowerCase();break}var s,r})}async Xe(e){console.log("Sending heartbeat to telemetry server...");let t=GM_getValue("bmUserSettings","{}");if(t=JSON.parse(t),!t||!t.telemetry||!t.uuid)return void console.log("Telemetry is disabled, not sending heartbeat.");const n=navigator.userAgent;let i=await o(this,h,b).call(this,n),s=o(this,h,p).call(this,n);GM_xmlhttpRequest({method:"POST",url:"https://telemetry.thebluecorner.net/heartbeat",headers:{"Content-Type":"application/json"},data:JSON.stringify({uuid:t.uuid,version:e,browser:i,os:s}),onload:e=>{200!==e.status&&r("Failed to send heartbeat:",e.statusText)},onerror:e=>{r("Error sending heartbeat:",e)}})}}(S);x.u(M);var O=JSON.parse(GM_getValue("bmTemplates","{}"));console.log(O),S.Fe(O);var T=JSON.parse(GM_getValue("bmUserSettings","{}"));if(console.log(T),console.log(Object.keys(T).length),0==Object.keys(T).length){const e=crypto.randomUUID();console.log(e),GM.setValue("bmUserSettings",JSON.stringify({uuid:e}))}if(setInterval(()=>M.Xe(y),18e5),console.log(`Telemetry is ${!(null==T?.telemetry)}`),null==T?.telemetry||T?.telemetry>1){const e=new s(w,y);e.u(M),e.$({id:"bm-d",style:"top: 0px; left: 0px; width: 100vw; max-width: 100vw; height: 100vh; max-height: 100vh; z-index: 9999;"}).$({id:"bm-7",style:"display: flex; flex-direction: column; align-items: center;"}).$({id:"bm-1",style:"margin-top: 10%;"}).O(1,{textContent:`${w} Telemetry`}).h().h().$({id:"bm-e",style:"max-width: 50%; overflow-y: auto; max-height: 80vh;"}).T().h().D().h().$({style:"width: fit-content; margin: auto; text-align: center;"}).C({id:"bm-8",textContent:"More Information"},(e,t)=>{t.onclick=()=>{window.open("https://github.com/SwingTheVine/Wplace-TelemetryServer#telemetry-data","_blank","noopener noreferrer")}}).h().h().D().h().$({style:"width: fit-content; margin: auto; text-align: center;"}).C({id:"bm-5",textContent:"Enable Telemetry",style:"margin-right: 2ch;"},(e,t)=>{t.onclick=()=>{const e=JSON.parse(GM_getValue("bmUserSettings","{}"));e.telemetry=1,GM.setValue("bmUserSettings",JSON.stringify(e));const t=document.getElementById("bm-d");t&&(t.style.display="none")}}).h().C({id:"bm-2",textContent:"Disable Telemetry"},(e,t)=>{t.onclick=()=>{const e=JSON.parse(GM_getValue("bmUserSettings","{}"));e.telemetry=0,GM.setValue("bmUserSettings",JSON.stringify(e));const t=document.getElementById("bm-d");t&&(t.style.display="none")}}).h().h().D().h().v({textContent:"We collect anonymous telemetry data such as your browser, OS, and script version to make the experience better for everyone. The data is never shared personally. The data is never sold. You can turn this off by pressing the 'Disable' button, but keeping it on helps us improve features and reliability faster. Thank you for supporting the Blue Marble!"}).h().v({textContent:'You can disable telemetry by pressing the "Disable" button below.'}).h().h().h().p(document.body)}!function(){let e=!1,t={};try{t=JSON.parse(GM_getValue("bmCoords","{}"))||{}}catch(e){t={}}const n=()=>{try{const e=Number(document.querySelector("#bm-v")?.value||""),t=Number(document.querySelector("#bm-w")?.value||""),n={qe:e,Ye:t,px:Number(document.querySelector("#bm-x")?.value||""),Ue:Number(document.querySelector("#bm-y")?.value||"")};GM.setValue("bmCoords",JSON.stringify(n))}catch(e){}};x.$({id:"bm-A",style:"top: 10px; right: 75px;"}).$({id:"bm-j"}).$({id:"bm-z"}).h().M({alt:"Blue Marble Icon - Click to minimize/maximize",src:"https://raw.githubusercontent.com/SwingTheVine/Wplace-BlueMarble/main/dist/assets/Favicon.png",style:"cursor: pointer;"},(t,n)=>{n.addEventListener("click",()=>{e=!e;const i=document.querySelector("#bm-A"),o=document.querySelector("#bm-j"),s=document.querySelector("#bm-z"),r=document.querySelector("#bm-k"),a=document.querySelector("#bm-q"),l=document.querySelector("#bm-r"),c=document.querySelector("#bm-s"),m=document.querySelector("#bm-l"),u=document.querySelectorAll("#bm-k input");e||(i.style.width="auto",i.style.maxWidth="300px",i.style.minWidth="200px",i.style.padding="10px"),["#bm-A h1","#bm-f","#bm-A hr","#bm-c > *:not(#bm-k)","#bm-a","#bm-6",`#${t.i}`,"#bm-9"].forEach(t=>{document.querySelectorAll(t).forEach(t=>{t.style.display=e?"none":""})}),e?(r&&(r.style.display="none"),a&&(a.style.display="none"),l&&(l.style.display="none"),c&&(c.style.display="none"),m&&(m.style.display="none"),u.forEach(e=>{e.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")):(r&&(r.style.display="",r.style.flexDirection="",r.style.justifyContent="",r.style.alignItems="",r.style.gap="",r.style.textAlign="",r.style.margin=""),a&&(a.style.display=""),l&&(l.style.display="",l.style.marginTop=""),c&&(c.style.display="",c.style.marginTop=""),m&&(m.style.display="",m.style.marginTop=""),u.forEach(e=>{e.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=e?"Blue Marble Icon - Minimized (Click to maximize)":"Blue Marble Icon - Maximized (Click to minimize)"})}).h().O(1,{textContent:w}).h().h().T().h().$({id:"bm-f"}).v({id:"bm-u",textContent:"Username:"}).h().v({id:"bm-p",textContent:"Droplets:"}).h().v({id:"bm-i",textContent:"Next level in..."}).h().h().T().h().$({id:"bm-c"}).$({id:"bm-k"}).C({id:"bm-q",className:"bm-D",style:"margin-top: 0;",innerHTML:''},(e,t)=>{t.onclick=()=>{const t=e.t?.je;t?.[0]?(e.B("bm-v",t?.[0]||""),e.B("bm-w",t?.[1]||""),e.B("bm-x",t?.[2]||""),e.B("bm-y",t?.[3]||""),n()):e.W("Coordinates are malformed! Did you try clicking on the canvas first?")}}).h().I({type:"number",id:"bm-v",placeholder:"Tl X",min:0,max:2047,step:1,required:!0,value:t.qe??""},(e,t)=>{t.addEventListener("paste",e=>{let t=(e.clipboardData||window.clipboardData).getData("text").split(" ").filter(e=>e).map(Number).filter(e=>!isNaN(e));if(4!==t.length)return;let n=(i=document,coords=[],coords.push(i.querySelector("#bm-v")),coords.push(i.querySelector("#bm-w")),coords.push(i.querySelector("#bm-x")),coords.push(i.querySelector("#bm-y")),coords);var i;for(let e=0;en();t.addEventListener("input",i),t.addEventListener("change",i)}).h().I({type:"number",id:"bm-w",placeholder:"Tl Y",min:0,max:2047,step:1,required:!0,value:t.Ye??""},(e,t)=>{const i=()=>n();t.addEventListener("input",i),t.addEventListener("change",i)}).h().I({type:"number",id:"bm-x",placeholder:"Px X",min:0,max:2047,step:1,required:!0,value:t.px??""},(e,t)=>{const i=()=>n();t.addEventListener("input",i),t.addEventListener("change",i)}).h().I({type:"number",id:"bm-y",placeholder:"Px Y",min:0,max:2047,step:1,required:!0,value:t.Ue??""},(e,t)=>{const i=()=>n();t.addEventListener("input",i),t.addEventListener("change",i)}).h().h().$({id:"bm-9",style:"max-height: 140px; overflow: auto; border: 1px solid rgba(255,255,255,0.1); padding: 4px; border-radius: 4px; display: none;"}).$({style:"display: flex; gap: 6px; margin-bottom: 6px;"}).C({id:"bm-3",textContent:"Enable All"},(e,t)=>{t.onclick=()=>{const t=S.se[0];t?.Y&&(Object.values(t.Y).forEach(e=>e.enabled=!0),buildColorFilterList(),e.F("Enabled all colors"))}}).h().C({id:"bm-0",textContent:"Disable All"},(e,t)=>{t.onclick=()=>{const t=S.se[0];t?.Y&&(Object.values(t.Y).forEach(e=>e.enabled=!1),buildColorFilterList(),e.F("Disabled all colors"))}}).h().h().$({id:"bm-g"}).h().h().L({id:"bm-a",textContent:"Upload Template",accept:"image/png, image/jpeg, image/webp, image/bmp, image/gif"}).h().$({id:"bm-4"}).C({id:"bm-s",textContent:"Enable"},(e,t)=>{t.onclick=()=>{e.t?.Ee?._e(!0),e.F("Enabled templates!")}}).h().C({id:"bm-r",textContent:"Create"},(e,t)=>{t.onclick=()=>{const t=document.querySelector("#bm-a"),n=document.querySelector("#bm-v");if(!n.checkValidity())return n.reportValidity(),void e.W("Coordinates are malformed! Did you try clicking on the canvas first?");const i=document.querySelector("#bm-w");if(!i.checkValidity())return i.reportValidity(),void e.W("Coordinates are malformed! Did you try clicking on the canvas first?");const o=document.querySelector("#bm-x");if(!o.checkValidity())return o.reportValidity(),void e.W("Coordinates are malformed! Did you try clicking on the canvas first?");const s=document.querySelector("#bm-y");if(!s.checkValidity())return s.reportValidity(),void e.W("Coordinates are malformed! Did you try clicking on the canvas first?");t?.files[0]?(S.ke(t.files[0],t.files[0]?.name.replace(/\.[^/.]+$/,""),[Number(n.value),Number(i.value),Number(o.value),Number(s.value)]),e.F("Drew to canvas!")):e.W("No file selected!")}}).h().C({id:"bm-l",textContent:"Disable"},(e,t)=>{t.onclick=()=>{e.t?.Ee?._e(!1),e.F("Disabled templates!")}}).h().h().G({id:x.i,placeholder:`Status: Sleeping...\nVersion: ${y}`,readOnly:!0}).h().$({id:"bm-6"}).$().C({id:"bm-m",className:"bm-D",innerHTML:"🎨",title:"Template Color Converter"},(e,t)=>{t.addEventListener("click",()=>{window.open("https://pepoafonso.github.io/color_converter_wplace/","_blank","noopener noreferrer")})}).h().C({id:"bm-n",className:"bm-D",innerHTML:"🌐",title:"Official Blue Marble Website"},(e,t)=>{t.addEventListener("click",()=>{window.open("https://bluemarble.camilledaguin.fr/","_blank","noopener noreferrer")})}).h().h().S({textContent:"Made by SwingTheVine",style:"margin-top: auto;"}).h().h().h().p(document.body),window.buildColorFilterList=function(){const e=document.querySelector("#bm-g"),t=S.se?.[0];if(!e||!t?.Y)return void(e&&(e.innerHTML="No template colors to display."));e.innerHTML="";const n=Object.entries(t.Y).sort((e,t)=>t[1].count-e[1].count);for(const[t,i]of n){let n=document.createElement("div");n.style.display="flex",n.style.alignItems="center",n.style.gap="8px",n.style.margin="4px 0";let o=document.createElement("div");o.style.width="14px",o.style.height="14px",o.style.border="1px solid rgba(255,255,255,0.5)";let s=document.createElement("span");s.style.fontSize="12px";let r=`${i.count.toLocaleString()}`;if("other"===t)o.style.background="#888",r=`Other • ${r}`;else if("#deface"===t)o.style.background="#deface",r=`Transparent • ${r}`;else{const[e,n,i]=t.split(",").map(Number);o.style.background=`rgb(${e},${n},${i})`;try{const o=S.se?.[0]?.K?.get(t);if(o&&"number"==typeof o.id){const t=o?.name||`rgb(${e},${n},${i})`,s=o.premium?"★ ":"";r=`#${o.id} ${s}${t} • ${r}`}}catch(e){}}s.textContent=r;const a=document.createElement("input");a.type="checkbox",a.checked=!!i.enabled,a.addEventListener("change",()=>{i.enabled=a.checked,x.F(`${a.checked?"Enabled":"Disabled"} ${t}`);try{const e=S.se?.[0],t=e?.V;e&&t&&S.ie?.templates?.[t]&&(S.ie.templates[t].palette=e.Y,GM.setValue("bmTemplates",JSON.stringify(S.ie)))}catch(e){}}),n.appendChild(a),n.appendChild(o),n.appendChild(s),e.appendChild(n)}},window.addEventListener("message",e=>{if("bm-b"===e?.data?.re)try{buildColorFilterList()}catch(e){}}),setTimeout(()=>{try{if(S.se?.length>0){const e=document.querySelector("#bm-9");e&&(e.style.display=""),buildColorFilterList()}}catch(e){}},0)}(),x.P("#bm-A","#bm-z"),M.Re(x),new MutationObserver((e,t)=>{const n=document.querySelector("#color-1");if(!n)return;let i=document.querySelector("#bm-t");if(!i){i=document.createElement("button"),i.id="bm-t",i.textContent="Move ↑",i.className="btn btn-soft",i.onclick=function(){const e=this.parentNode.parentNode.parentNode.parentNode,t="Move ↑"==this.textContent;e.parentNode.className=e.parentNode.className.replace(t?"bottom":"top",t?"top":"bottom"),e.style.borderTopLeftRadius=t?"0px":"var(--radius-box)",e.style.borderTopRightRadius=t?"0px":"var(--radius-box)",e.style.borderBottomLeftRadius=t?"var(--radius-box)":"0px",e.style.borderBottomRightRadius=t?"var(--radius-box)":"0px",this.textContent=t?"Move ↓":"Move ↑"};const e=n.parentNode.parentNode.parentNode.parentNode.querySelector("h2");e.parentNode?.appendChild(i)}}).observe(document.body,{childList:!0,subtree:!0}),function(...e){(0,console.log)(...e)}(`%c${w}%c (${y}) userscript has loaded!`,"color: cornflowerblue;","")})();
\ No newline at end of file
+(()=>{var e,t,n=e=>{throw TypeError(e)},i=(e,t,i)=>t.has(e)?n("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,i),o=(e,t,i)=>(((e,t)=>{t.has(e)||n("Cannot access private method")})(e,t),i),s=class{constructor(t,n){i(this,e),this.name=t,this.version=n,this.t=null,this.i="bm-o",this.o=null,this.l=null,this.m=[]}u(e){this.t=e}h(){return this.m.length>0&&(this.l=this.m.pop()),this}p(e){e?.appendChild(this.o),this.o=null,this.l=null,this.m=[]}v(n={},i=()=>{}){return i(this,o(this,e,t).call(this,"div",{},n)),this}$(n={},i=()=>{}){return i(this,o(this,e,t).call(this,"p",{},n)),this}S(n={},i=()=>{}){return i(this,o(this,e,t).call(this,"small",{},n)),this}M(n={},i=()=>{}){return i(this,o(this,e,t).call(this,"img",{},n)),this}O(n,i={},s=()=>{}){return s(this,o(this,e,t).call(this,"h"+n,{},i)),this}T(n={},i=()=>{}){return i(this,o(this,e,t).call(this,"hr",{},n)),this}D(n={},i=()=>{}){return i(this,o(this,e,t).call(this,"br",{},n)),this}k(n={},i=()=>{}){const s=o(this,e,t).call(this,"label",{textContent:n.textContent??""});delete n.textContent;const r=o(this,e,t).call(this,"input",{type:"checkbox"},n);return s.insertBefore(r,s.firstChild),this.h(),i(this,s,r),this}C(n={},i=()=>{}){return i(this,o(this,e,t).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 r={textContent:"?",className:"bm-D",onclick:()=>{this.B(this.i,s)}};return i(this,o(this,e,t).call(this,"button",r,n)),this}I(n={},i=()=>{}){return i(this,o(this,e,t).call(this,"input",{},n)),this}L(n={},i=()=>{}){const s=n.textContent??"";delete n.textContent;const r=o(this,e,t).call(this,"div"),a=o(this,e,t).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.h();const l=o(this,e,t).call(this,"button",{textContent:s});return this.h(),this.h(),a.setAttribute("tabindex","-1"),a.setAttribute("aria-hidden","true"),l.addEventListener("click",()=>{a.click()}),a.addEventListener("change",()=>{l.style.maxWidth=`${l.offsetWidth}px`,a.files.length>0?l.textContent=a.files[0].name:l.textContent=s}),i(this,r,a,l),this}G(n={},i=()=>{}){return i(this,o(this,e,t).call(this,"textarea",{},n)),this}B(e,t,n=!1){const i=document.getElementById(e.replace(/^#/,""));i&&(i instanceof HTMLInputElement?i.value=t:n?i.textContent=t:i.innerHTML=t)}P(e,t){let n,i=!1,o=0,s=null,r=0,a=0,l=0,c=0;if(e=document.querySelector("#"==e?.[0]?e:"#"+e),t=document.querySelector("#"==t?.[0]?t:"#"+t),!e||!t)return void this.W(`Can not drag! ${e?"":"moveMe"} ${e||t?"":"and "}${t?"":"iMoveThings "}was not found!`);const m=()=>{if(i){const t=Math.abs(r-l),n=Math.abs(a-c);(t>.5||n>.5)&&(r=l,a=c,e.style.transform=`translate(${r}px, ${a}px)`,e.style.left="0px",e.style.top="0px",e.style.right=""),s=requestAnimationFrame(m)}};let u=null;const d=(d,h)=>{i=!0,u=e.getBoundingClientRect(),n=d-u.left,o=h-u.top;const b=window.getComputedStyle(e).transform;if(b&&"none"!==b){const e=new DOMMatrix(b);r=e.m41,a=e.m42}else r=u.left,a=u.top;l=r,c=a,document.body.style.userSelect="none",t.classList.add("dragging"),s&&cancelAnimationFrame(s),m()},h=()=>{i=!1,s&&(cancelAnimationFrame(s),s=null),document.body.style.userSelect="",t.classList.remove("dragging")};t.addEventListener("mousedown",function(e){e.preventDefault(),d(e.clientX,e.clientY)}),t.addEventListener("touchstart",function(e){const t=e?.touches?.[0];t&&(d(t.clientX,t.clientY),e.preventDefault())},{passive:!1}),document.addEventListener("mousemove",function(e){i&&u&&(l=e.clientX-n,c=e.clientY-o)},{passive:!0}),document.addEventListener("touchmove",function(e){if(i&&u){const t=e?.touches?.[0];if(!t)return;l=t.clientX-n,c=t.clientY-o,e.preventDefault()}},{passive:!1}),document.addEventListener("mouseup",h),document.addEventListener("touchend",h),document.addEventListener("touchcancel",h)}F(e){(0,console.info)(`${this.name}: ${e}`),this.B(this.i,"Status: "+e,!0)}W(e){(0,console.error)(`${this.name}: ${e}`),this.B(this.i,"Error: "+e,!0)}};function r(...e){(0,console.error)(...e)}function a(e,t){if(0===e)return t[0];let n="";const i=t.length;for(;e>0;)n=t[e%i]+n,e=Math.floor(e/i);return n}function l(e){let t="";for(let n=0;n"transparent"!==(e?.name||"").toLowerCase()&&Array.isArray(e?.rgb)).map(e=>`${e.rgb[0]},${e.rgb[1]},${e.rgb[2]}`));const c="222,250,206";this.H.add(c),this.K=new Map(l.filter(e=>Array.isArray(e?.rgb)).map(e=>[`${e.rgb[0]},${e.rgb[1]},${e.rgb[2]}`,{id:e.id,premium:!!e.premium,name:e.name}]));try{const e=l.find(e=>"transparent"===(e?.name||"").toLowerCase());e&&Array.isArray(e.rgb)&&this.K.set(c,{id:e.id,premium:!!e.premium,name:e.name})}catch(e){}}async Z(){console.log("Template coordinates:",this.coords);const e=await createImageBitmap(this.file),t=e.width,n=e.height,i=t*n;console.log(`Template pixel analysis - Dimensions: ${t}×${n} = ${i.toLocaleString()} pixels`),this.X=i;try{const i=new OffscreenCanvas(t,n).getContext("2d",{ee:!0});i.imageSmoothingEnabled=!1,i.clearRect(0,0,t,n),i.drawImage(e,0,0);const o=i.getImageData(0,0,t,n).data;let s=0,r=0;const a=new Map;for(let e=0;e0){for(const e in t){const n=e,i=t[e];if(console.log(n),t.hasOwnProperty(e)){const e=n.split(" "),o=Number(e?.[0]),s=e?.[1]||"0",r=i.name||`Template ${o||""}`,a=i.tiles,l={};let m=0;const u=new Map;for(const e in a)if(console.log(e),a.hasOwnProperty(e)){const t=c(a[e]),n=new Blob([t],{type:"image/png"}),i=await createImageBitmap(n);l[e]=i;try{const e=i.width,t=i.height,n=new OffscreenCanvas(e,t).getContext("2d",{ee:!0});n.imageSmoothingEnabled=!1,n.clearRect(0,0,e,t),n.drawImage(i,0,0);const o=n.getImageData(0,0,e,t).data;for(let n=0;n{d.U?.add(e.split(",").slice(0,2).join(","))})}catch(e){}try{const e=t?.[n]?.palette;if(e)for(const[t,n]of Object.entries(e))d.Y[t]?d.Y[t].enabled=!!n?.enabled:d.Y[t]={count:n?.count||0,enabled:!!n?.enabled}}catch(e){}d.V=n,this.se.push(d),console.log(this.se),console.log("^^^ This ^^^")}}try{const e=document.querySelector("#bm-9");e&&(e.style.display=""),window.postMessage({source:"blue-marble",re:"bm-b"},"*")}catch(e){}}},h=new WeakSet,b=async function(e=navigator.userAgent){return(e=e||"").includes("OPR/")||e.includes("Opera")?"Opera":e.includes("Edg/")?"Edge":e.includes("Vivaldi")?"Vivaldi":e.includes("YaBrowser")?"Yandex":e.includes("Kiwi")?"Kiwi":e.includes("Brave")?"Brave":e.includes("Firefox/")?"Firefox":e.includes("Chrome/")?"Chrome":e.includes("Safari/")?"Safari":navigator.brave&&"function"==typeof navigator.brave.isBrave&&await navigator.brave.isBrave()?"Brave":"Unknown"},p=function(e=navigator.userAgent){return/Windows NT 11/i.test(e=e||"")?"Windows 11":/Windows NT 10/i.test(e)?"Windows 10":/Windows NT 6\.3/i.test(e)?"Windows 8.1":/Windows NT 6\.2/i.test(e)?"Windows 8":/Windows NT 6\.1/i.test(e)?"Windows 7":/Windows NT 6\.0/i.test(e)?"Windows Vista":/Windows NT 5\.1|Windows XP/i.test(e)?"Windows XP":/Mac OS X 10[_\.]15/i.test(e)?"macOS Catalina":/Mac OS X 10[_\.]14/i.test(e)?"macOS Mojave":/Mac OS X 10[_\.]13/i.test(e)?"macOS High Sierra":/Mac OS X 10[_\.]12/i.test(e)?"macOS Sierra":/Mac OS X 10[_\.]11/i.test(e)?"OS X El Capitan":/Mac OS X 10[_\.]10/i.test(e)?"OS X Yosemite":/Mac OS X 10[_\.]/i.test(e)?"macOS":/Android/i.test(e)?"Android":/iPhone|iPad|iPod/i.test(e)?"iOS":/Linux/i.test(e)?"Linux":"Unknown"};var w=GM_info.script.name.toString(),y=GM_info.script.version.toString();!function(e){const t=document.createElement("script");t.setAttribute("bm-E",w),t.setAttribute("bm-B","color: cornflowerblue;"),t.textContent=`(${e})();`,document.documentElement?.appendChild(t),t.remove()}(()=>{const e=document.currentScript,t=e?.getAttribute("bm-E")||"Blue Marble",n=e?.getAttribute("bm-B")||"",i=new Map;window.addEventListener("message",e=>{const{source:o,endpoint:s,blobID:r,blobData:a,blink:l}=e.data,c=Date.now()-l;if(console.groupCollapsed(`%c${t}%c: ${i.size} Recieved IMAGE message about blob "${r}"`,n,""),console.log(`Blob fetch took %c${String(Math.floor(c/6e4)).padStart(2,"0")}:${String(Math.floor(c/1e3)%60).padStart(2,"0")}.${String(c%1e3).padStart(3,"0")}%c MM:SS.mmm`,n,""),console.log(i),console.groupEnd(),"blue-marble"==o&&r&&a&&!s){const e=i.get(r);"function"==typeof e?e(a):function(...e){(0,console.warn)(...e)}(`%c${t}%c: Attempted to retrieve a blob (%s) from queue, but the blobID was not a function! Skipping...`,n,"",r),i.delete(r)}});const o=window.fetch;window.fetch=async function(...e){const s=await o.apply(this,e),r=s.clone(),a=(e[0]instanceof Request?e[0]?.url:e[0])||"ignore",l=r.headers.get("content-type")||"";if(l.includes("application/json"))console.log(`%c${t}%c: Sending JSON message about endpoint "${a}"`,n,""),r.json().then(e=>{window.postMessage({source:"blue-marble",endpoint:a,jsonData:e},"*")}).catch(e=>{console.error(`%c${t}%c: Failed to parse JSON: `,n,"",e)});else if(l.includes("image/")&&!a.includes("openfreemap")&&!a.includes("maps")){const e=Date.now(),o=await r.blob();return console.log(`%c${t}%c: ${i.size} Sending IMAGE message about endpoint "${a}"`,n,""),new Promise(s=>{const l=crypto.randomUUID();i.set(l,e=>{s(new Response(e,{headers:r.headers,status:r.status,statusText:r.statusText})),console.log(`%c${t}%c: ${i.size} Processed blob "${l}"`,n,"")}),window.postMessage({source:"blue-marble",endpoint:a,blobID:l,blobData:o,blink:e})}).catch(o=>{const s=Date.now();console.error(`%c${t}%c: Failed to Promise blob!`,n,""),console.groupCollapsed(`%c${t}%c: Details of failed blob Promise:`,n,""),console.log(`Endpoint: ${a}\nThere are ${i.size} blobs processing...\nBlink: ${e.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 v=GM_getResourceText("CSS-BM-File");GM_addStyle(v);var $=document.createElement("link");$.href="https://fonts.googleapis.com/css2?family=Roboto+Mono:ital,wght@0,100..700;1,100..700&display=swap",$.rel="preload",$.as="style",$.onload=function(){this.onload=null,this.rel="stylesheet"},document.head?.appendChild($),new class{constructor(){this.ae=null,this.le=null,this.ce="#bm-h"}me(e){return this.le=e,this.ae=new MutationObserver(e=>{for(const t of e)for(const e of t.addedNodes)e instanceof HTMLElement&&e.matches?.(this.ce)}),this}ue(){return this.ae}observe(e,t=!1,n=!1){e.observe(this.le,{childList:t,subtree:n})}};var x=new s(w,y),S=(new s(w,y),new class{constructor(e,t,n){i(this,m),this.name=e,this.version=t,this.o=n,this.de="1.0.0",this.he=null,this.be="!#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwxyz{|}~",this.R=1e3,this.oe=3,this.pe=null,this.ge=null,this.fe="bm-C",this.we="div#map canvas.maplibregl-canvas",this.ye=null,this.ve="",this.se=[],this.ie=null,this.$e=!0,this.xe=new Map}Se(){if(document.body.contains(this.pe))return this.pe;document.getElementById(this.fe)?.remove();const e=document.querySelector(this.we),t=document.createElement("canvas");return t.id=this.fe,t.className="maplibregl-canvas",t.style.position="absolute",t.style.top="0",t.style.left="0",t.style.height=e?.clientHeight*(window.devicePixelRatio||1)+"px",t.style.width=e?.clientWidth*(window.devicePixelRatio||1)+"px",t.height=e?.clientHeight*(window.devicePixelRatio||1),t.width=e?.clientWidth*(window.devicePixelRatio||1),t.style.zIndex="8999",t.style.pointerEvents="none",e?.parentElement?.appendChild(t),this.pe=t,window.addEventListener("move",this.Me),window.addEventListener("zoom",this.Oe),window.addEventListener("resize",this.Te),this.pe}async De(){return{whoami:this.name.replace(" ",""),scriptVersion:this.version,schemaVersion:this.de,templates:{}}}async ke(e,t,n){this.ie||(this.ie=await this.De(),console.log("Creating JSON...")),this.o.F(`Creating template at ${n.join(", ")}...`);const i=new f({displayName:t,_:0,J:a(this.he||0,this.be),file:e,coords:n}),{te:s,ne:r}=await i.Z(this.R);i.j=s;const l=`${i._} ${i.J}`;i.V=l,this.ie.templates[l]={name:i.displayName,coords:n.join(", "),enabled:!0,tiles:r,palette:i.Y},this.se=[],this.se.push(i);const c=(new Intl.NumberFormat).format(i.X);this.o.F(`Template created at ${n.join(", ")}! Total pixels: ${c}`);try{const e=document.querySelector("#bm-9");e&&(e.style.display=""),window.postMessage({source:"blue-marble",re:"bm-b"},"*")}catch(e){}console.log(Object.keys(this.ie.templates).length),console.log(this.ie),console.log(this.se),console.log(JSON.stringify(this.ie)),await o(this,m,u).call(this)}Ce(){}async Ne(){this.ie||(this.ie=await this.De(),console.log("Creating JSON..."))}async Be(e,t){if(!this.$e)return e;const n=this.R*this.oe;t=t[0].toString().padStart(4,"0")+","+t[1].toString().padStart(4,"0"),console.log(`Searching for templates in tile: "${t}"`);const i=this.se;if(console.log(i),i.sort((e,t)=>e._-t._),console.log(i),!i.some(e=>!!e?.j&&(e.U&&e.U.size>0?e.U.has(t):Object.keys(e.j).some(e=>e.startsWith(t)))))return e;const o=i.map(e=>{const n=Object.keys(e.j).filter(e=>e.startsWith(t));if(0===n.length)return null;const i=n.map(t=>{const n=t.split(",");return{Ie:e.j[t],Le:[n[0],n[1]],Ge:[n[2],n[3]]}});return i?.[0]}).filter(Boolean);console.log(o);const s=o?.length||0;console.log(`templateCount = ${s}`);let r=0,a=0,l=0;const c=await createImageBitmap(e),m=new OffscreenCanvas(n,n),u=m.getContext("2d");u.imageSmoothingEnabled=!1,u.beginPath(),u.rect(0,0,n,n),u.clip(),u.clearRect(0,0,n,n),u.drawImage(c,0,0,n,n);let d=null;try{d=u.getImageData(0,0,n,n).data}catch(e){}for(const e of o){if(console.log("Template:"),console.log(e),d)try{const t=e.Ie.width,i=e.Ie.height,o=new OffscreenCanvas(t,i).getContext("2d",{ee:!0});o.imageSmoothingEnabled=!1,o.clearRect(0,0,t,i),o.drawImage(e.Ie,0,0);const s=o.getImageData(0,0,t,i).data,c=Number(e.Ge[0])*this.oe,m=Number(e.Ge[1])*this.oe;for(let e=0;e=n||u>=n)continue;const h=4*(e*t+i),b=s[h],p=s[h+1],g=s[h+2];if(s[h+3]<64){try{const e=this.se?.[0],t=4*(u*n+o),i=d[t],s=d[t+1],r=d[t+2],l=d[t+3],c=`${i},${s},${r}`,m=!!e?.H&&e.H.has(c);l>=64&&m&&a++}catch(e){}continue}try{const e=this.se?.[0];if(e?.H&&!e.H.has(`${b},${p},${g}`))continue}catch(e){}l++;const f=4*(u*n+o),w=d[f],y=d[f+1],v=d[f+2];d[f+3]<64||(w===b&&y===p&&v===g?r++:a++)}}catch(e){console.warn("Failed to compute per-tile painted/wrong stats:",e)}try{const t=this.se?.[0],n=t?.Y||{};if(Object.values(n).some(e=>!1===e?.enabled)){const i=e.Ie.width,o=e.Ie.height,s=new OffscreenCanvas(i,o),r=s.getContext("2d",{ee:!0});r.imageSmoothingEnabled=!1,r.clearRect(0,0,i,o),r.drawImage(e.Ie,0,0);const a=r.getImageData(0,0,i,o),l=a.data;for(let e=0;e0){const e=t;this.xe.set(e,{Pe:r,required:l,We:a});let n=0,i=0,o=0;for(const e of this.xe.values())n+=e.Pe||0,i+=e.required||0,o+=e.We||0;const c=this.se.reduce((e,t)=>e+(t.A||t.X||0),0),m=c>0?c:i,u=(new Intl.NumberFormat).format(n),d=(new Intl.NumberFormat).format(m),h=(new Intl.NumberFormat).format(m-n);this.o.F(`Displaying ${s} template${1==s?"":"s"}.\nPainted ${u} / ${d} • Wrong ${h}`)}else this.o.F(`Displaying ${s} templates.`);return await m.convertToBlob({type:"image/png"})}Fe(e){console.log("Importing JSON..."),console.log(e),"BlueMarble"==e?.whoami&&o(this,m,d).call(this,e)}_e(e){this.$e=e}}(w,y,x)),M=new class{constructor(e){i(this,h),this.Ee=e,this.Je=!1,this.je=[],this.Re=[]}Xe(e){window.addEventListener("message",async t=>{const n=t.data,i=n.jsonData;if(!n||"blue-marble"!==n.source)return;if(!n.endpoint)return;const o=n.endpoint?.split("?")[0].split("/").filter(e=>e&&isNaN(Number(e))).filter(e=>e&&!e.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 e.W("You are not logged in!\nCould not fetch userdata.");const t=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.Ee.he=i.id,e.B("bm-u",`Username: ${function(e){const t=document.createElement("div");return t.textContent=e,t.innerHTML}(i.name)}`),e.B("bm-p",`Droplets: ${(new Intl.NumberFormat).format(i.droplets)}`),e.B("bm-i",`Next level in ${(new Intl.NumberFormat).format(t)} pixel${1==t?"":"s"}`);break;case"pixel":const o=n.endpoint.split("?")[0].split("/").filter(e=>e&&!isNaN(Number(e))),l=new URLSearchParams(n.endpoint.split("?")[1]),c=[l.get("x"),l.get("y")];if(this.je.length&&(!o.length||!c.length))return void e.W("Coordinates are malformed!\nDid you try clicking the canvas first?");this.je=[...o,...c];const m=(s=o,r=c,[parseInt(s[0])%4*1e3+parseInt(r[0]),parseInt(s[1])%4*1e3+parseInt(r[1])]),u=document.querySelectorAll("span");for(const e of u)if(e.textContent.trim().includes(`${m[0]}, ${m[1]}`)){let t=document.querySelector("#bm-h");const n=`(Tl X: ${o[0]}, Tl Y: ${o[1]}, Px X: ${c[0]}, Px Y: ${c[1]})`;t?t.textContent=n:(t=document.createElement("span"),t.id="bm-h",t.textContent=n,t.style="margin-left: calc(var(--spacing)*3); font-size: small;",e.parentNode.parentNode.parentNode.insertAdjacentElement("afterend",t))}break;case"tiles":let d=n.endpoint.split("/");d=[parseInt(d[d.length-2]),parseInt(d[d.length-1].replace(".png",""))];const h=n.blobID,b=n.blobData,p=await this.Ee.Be(b,d);window.postMessage({source:"blue-marble",blobID:h,blobData:p,blink:n.blink});break;case"robots":this.Je="false"==i.userscript?.toString().toLowerCase();break}var s,r})}async Ae(e){console.log("Sending heartbeat to telemetry server...");let t=GM_getValue("bmUserSettings","{}");if(t=JSON.parse(t),!t||!t.telemetry||!t.uuid)return void console.log("Telemetry is disabled, not sending heartbeat.");const n=navigator.userAgent;let i=await o(this,h,b).call(this,n),s=o(this,h,p).call(this,n);GM_xmlhttpRequest({method:"POST",url:"https://telemetry.thebluecorner.net/heartbeat",headers:{"Content-Type":"application/json"},data:JSON.stringify({uuid:t.uuid,version:e,browser:i,os:s}),onload:e=>{200!==e.status&&r("Failed to send heartbeat:",e.statusText)},onerror:e=>{r("Error sending heartbeat:",e)}})}}(S);x.u(M);var O=JSON.parse(GM_getValue("bmTemplates","{}"));console.log(O),S.Fe(O);var T=JSON.parse(GM_getValue("bmUserSettings","{}"));if(console.log(T),console.log(Object.keys(T).length),0==Object.keys(T).length){const e=crypto.randomUUID();console.log(e),GM.setValue("bmUserSettings",JSON.stringify({uuid:e}))}if(setInterval(()=>M.Ae(y),18e5),console.log(`Telemetry is ${!(null==T?.telemetry)}`),null==T?.telemetry||T?.telemetry>1){const e=new s(w,y);e.u(M),e.v({id:"bm-d",style:"top: 0px; left: 0px; width: 100vw; max-width: 100vw; height: 100vh; max-height: 100vh; z-index: 9999;"}).v({id:"bm-7",style:"display: flex; flex-direction: column; align-items: center;"}).v({id:"bm-1",style:"margin-top: 10%;"}).O(1,{textContent:`${w} Telemetry`}).h().h().v({id:"bm-e",style:"max-width: 50%; overflow-y: auto; max-height: 80vh;"}).T().h().D().h().v({style:"width: fit-content; margin: auto; text-align: center;"}).C({id:"bm-8",textContent:"More Information"},(e,t)=>{t.onclick=()=>{window.open("https://github.com/SwingTheVine/Wplace-TelemetryServer#telemetry-data","_blank","noopener noreferrer")}}).h().h().D().h().v({style:"width: fit-content; margin: auto; text-align: center;"}).C({id:"bm-5",textContent:"Enable Telemetry",style:"margin-right: 2ch;"},(e,t)=>{t.onclick=()=>{const e=JSON.parse(GM_getValue("bmUserSettings","{}"));e.telemetry=1,GM.setValue("bmUserSettings",JSON.stringify(e));const t=document.getElementById("bm-d");t&&(t.style.display="none")}}).h().C({id:"bm-2",textContent:"Disable Telemetry"},(e,t)=>{t.onclick=()=>{const e=JSON.parse(GM_getValue("bmUserSettings","{}"));e.telemetry=0,GM.setValue("bmUserSettings",JSON.stringify(e));const t=document.getElementById("bm-d");t&&(t.style.display="none")}}).h().h().D().h().$({textContent:"We collect anonymous telemetry data such as your browser, OS, and script version to make the experience better for everyone. The data is never shared personally. The data is never sold. You can turn this off by pressing the 'Disable' button, but keeping it on helps us improve features and reliability faster. Thank you for supporting the Blue Marble!"}).h().$({textContent:'You can disable telemetry by pressing the "Disable" button below.'}).h().h().h().p(document.body)}!function(){let e=!1,t={};try{t=JSON.parse(GM_getValue("bmCoords","{}"))||{}}catch(e){t={}}const n=()=>{try{const e=Number(document.querySelector("#bm-v")?.value||""),t=Number(document.querySelector("#bm-w")?.value||""),n={qe:e,Ye:t,px:Number(document.querySelector("#bm-x")?.value||""),Ue:Number(document.querySelector("#bm-y")?.value||"")};GM.setValue("bmCoords",JSON.stringify(n))}catch(e){}};x.v({id:"bm-A",style:"top: 10px; right: 75px;"}).v({id:"bm-j"}).v({id:"bm-z"}).h().M({alt:"Blue Marble Icon - Click to minimize/maximize",src:"https://raw.githubusercontent.com/SwingTheVine/Wplace-BlueMarble/main/dist/assets/Favicon.png",style:"cursor: pointer;"},(t,n)=>{n.addEventListener("click",()=>{e=!e;const i=document.querySelector("#bm-A"),o=document.querySelector("#bm-j"),s=document.querySelector("#bm-z"),r=document.querySelector("#bm-k"),a=document.querySelector("#bm-q"),l=document.querySelector("#bm-r"),c=document.querySelector("#bm-s"),m=document.querySelector("#bm-l"),u=document.querySelectorAll("#bm-k input");e||(i.style.width="auto",i.style.maxWidth="300px",i.style.minWidth="200px",i.style.padding="10px"),["#bm-A h1","#bm-f","#bm-A hr","#bm-c > *:not(#bm-k)","#bm-a","#bm-6",`#${t.i}`,"#bm-9"].forEach(t=>{document.querySelectorAll(t).forEach(t=>{t.style.display=e?"none":""})}),e?(r&&(r.style.display="none"),a&&(a.style.display="none"),l&&(l.style.display="none"),c&&(c.style.display="none"),m&&(m.style.display="none"),u.forEach(e=>{e.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")):(r&&(r.style.display="",r.style.flexDirection="",r.style.justifyContent="",r.style.alignItems="",r.style.gap="",r.style.textAlign="",r.style.margin=""),a&&(a.style.display=""),l&&(l.style.display="",l.style.marginTop=""),c&&(c.style.display="",c.style.marginTop=""),m&&(m.style.display="",m.style.marginTop=""),u.forEach(e=>{e.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=e?"Blue Marble Icon - Minimized (Click to maximize)":"Blue Marble Icon - Maximized (Click to minimize)"})}).h().O(1,{textContent:w}).h().h().T().h().v({id:"bm-f"}).$({id:"bm-u",textContent:"Username:"}).h().$({id:"bm-p",textContent:"Droplets:"}).h().$({id:"bm-i",textContent:"Next level in..."}).h().h().T().h().v({id:"bm-c"}).v({id:"bm-k"}).C({id:"bm-q",className:"bm-D",style:"margin-top: 0;",innerHTML:''},(e,t)=>{t.onclick=()=>{const t=e.t?.je;t?.[0]?(e.B("bm-v",t?.[0]||""),e.B("bm-w",t?.[1]||""),e.B("bm-x",t?.[2]||""),e.B("bm-y",t?.[3]||""),n()):e.W("Coordinates are malformed! Did you try clicking on the canvas first?")}}).h().I({type:"number",id:"bm-v",placeholder:"Tl X",min:0,max:2047,step:1,required:!0,value:t.qe??""},(e,t)=>{t.addEventListener("paste",e=>{let t=(e.clipboardData||window.clipboardData).getData("text").split(" ").filter(e=>e).map(Number).filter(e=>!isNaN(e));if(4!==t.length)return;let n=(i=document,coords=[],coords.push(i.querySelector("#bm-v")),coords.push(i.querySelector("#bm-w")),coords.push(i.querySelector("#bm-x")),coords.push(i.querySelector("#bm-y")),coords);var i;for(let e=0;en();t.addEventListener("input",i),t.addEventListener("change",i)}).h().I({type:"number",id:"bm-w",placeholder:"Tl Y",min:0,max:2047,step:1,required:!0,value:t.Ye??""},(e,t)=>{const i=()=>n();t.addEventListener("input",i),t.addEventListener("change",i)}).h().I({type:"number",id:"bm-x",placeholder:"Px X",min:0,max:2047,step:1,required:!0,value:t.px??""},(e,t)=>{const i=()=>n();t.addEventListener("input",i),t.addEventListener("change",i)}).h().I({type:"number",id:"bm-y",placeholder:"Px Y",min:0,max:2047,step:1,required:!0,value:t.Ue??""},(e,t)=>{const i=()=>n();t.addEventListener("input",i),t.addEventListener("change",i)}).h().h().v({id:"bm-9",style:"max-height: 140px; overflow: auto; border: 1px solid rgba(255,255,255,0.1); padding: 4px; border-radius: 4px; display: none;"}).v({style:"display: flex; gap: 6px; margin-bottom: 6px;"}).C({id:"bm-3",textContent:"Enable All"},(e,t)=>{t.onclick=()=>{const t=S.se[0];t?.Y&&(Object.values(t.Y).forEach(e=>e.enabled=!0),buildColorFilterList(),e.F("Enabled all colors"))}}).h().C({id:"bm-0",textContent:"Disable All"},(e,t)=>{t.onclick=()=>{const t=S.se[0];t?.Y&&(Object.values(t.Y).forEach(e=>e.enabled=!1),buildColorFilterList(),e.F("Disabled all colors"))}}).h().h().v({id:"bm-g"}).h().h().L({id:"bm-a",textContent:"Upload Template",accept:"image/png, image/jpeg, image/webp, image/bmp, image/gif"}).h().v({id:"bm-4"}).C({id:"bm-s",textContent:"Enable"},(e,t)=>{t.onclick=()=>{e.t?.Ee?._e(!0),e.F("Enabled templates!")}}).h().C({id:"bm-r",textContent:"Create"},(e,t)=>{t.onclick=()=>{const t=document.querySelector("#bm-a"),n=document.querySelector("#bm-v");if(!n.checkValidity())return n.reportValidity(),void e.W("Coordinates are malformed! Did you try clicking on the canvas first?");const i=document.querySelector("#bm-w");if(!i.checkValidity())return i.reportValidity(),void e.W("Coordinates are malformed! Did you try clicking on the canvas first?");const o=document.querySelector("#bm-x");if(!o.checkValidity())return o.reportValidity(),void e.W("Coordinates are malformed! Did you try clicking on the canvas first?");const s=document.querySelector("#bm-y");if(!s.checkValidity())return s.reportValidity(),void e.W("Coordinates are malformed! Did you try clicking on the canvas first?");t?.files[0]?(S.ke(t.files[0],t.files[0]?.name.replace(/\.[^/.]+$/,""),[Number(n.value),Number(i.value),Number(o.value),Number(s.value)]),e.F("Drew to canvas!")):e.W("No file selected!")}}).h().C({id:"bm-l",textContent:"Disable"},(e,t)=>{t.onclick=()=>{e.t?.Ee?._e(!1),e.F("Disabled templates!")}}).h().h().G({id:x.i,placeholder:`Status: Sleeping...\nVersion: ${y}`,readOnly:!0}).h().v({id:"bm-6"}).v().C({id:"bm-m",className:"bm-D",innerHTML:"🎨",title:"Template Color Converter"},(e,t)=>{t.addEventListener("click",()=>{window.open("https://pepoafonso.github.io/color_converter_wplace/","_blank","noopener noreferrer")})}).h().C({id:"bm-n",className:"bm-D",innerHTML:"🌐",title:"Official Blue Marble Website"},(e,t)=>{t.addEventListener("click",()=>{window.open("https://bluemarble.camilledaguin.fr/","_blank","noopener noreferrer")})}).h().h().S({textContent:"Made by SwingTheVine",style:"margin-top: auto;"}).h().h().h().p(document.body),window.buildColorFilterList=function(){const e=document.querySelector("#bm-g"),t=S.se?.[0];if(!e||!t?.Y)return void(e&&(e.innerHTML="No template colors to display."));e.innerHTML="";const n=Object.entries(t.Y).sort((e,t)=>t[1].count-e[1].count);for(const[t,i]of n){const[n,o,s]=t.split(",").map(Number),r=document.createElement("div");r.style.display="flex",r.style.alignItems="center",r.style.gap="8px",r.style.margin="4px 0";const a=document.createElement("div");a.style.width="14px",a.style.height="14px",a.style.border="1px solid rgba(255,255,255,0.5)",a.style.background=`rgb(${n},${o},${s})`;const l=document.createElement("span");l.style.fontSize="12px";let c=`${i.count.toLocaleString()}`;try{const e=S.se?.[0]?.K?.get(t);if(e&&"number"==typeof e.id){const t=e?.name||`rgb(${n},${o},${s})`,i=e.premium?"★ ":"";c=`#${e.id} ${i}${t} • ${c}`}}catch(e){}l.textContent=c;const m=document.createElement("input");m.type="checkbox",m.checked=!!i.enabled,m.addEventListener("change",()=>{i.enabled=m.checked,x.F(`${m.checked?"Enabled":"Disabled"} ${t}`);try{const e=S.se?.[0],t=e?.V;e&&t&&S.ie?.templates?.[t]&&(S.ie.templates[t].palette=e.Y,GM.setValue("bmTemplates",JSON.stringify(S.ie)))}catch(e){}}),r.appendChild(m),r.appendChild(a),r.appendChild(l),e.appendChild(r)}},window.addEventListener("message",e=>{if("bm-b"===e?.data?.re)try{buildColorFilterList()}catch(e){}}),setTimeout(()=>{try{if(S.se?.length>0){const e=document.querySelector("#bm-9");e&&(e.style.display=""),buildColorFilterList()}}catch(e){}},0)}(),x.P("#bm-A","#bm-z"),M.Xe(x),new MutationObserver((e,t)=>{const n=document.querySelector("#color-1");if(!n)return;let i=document.querySelector("#bm-t");if(!i){i=document.createElement("button"),i.id="bm-t",i.textContent="Move ↑",i.className="btn btn-soft",i.onclick=function(){const e=this.parentNode.parentNode.parentNode.parentNode,t="Move ↑"==this.textContent;e.parentNode.className=e.parentNode.className.replace(t?"bottom":"top",t?"top":"bottom"),e.style.borderTopLeftRadius=t?"0px":"var(--radius-box)",e.style.borderTopRightRadius=t?"0px":"var(--radius-box)",e.style.borderBottomLeftRadius=t?"var(--radius-box)":"0px",e.style.borderBottomRightRadius=t?"var(--radius-box)":"0px",this.textContent=t?"Move ↓":"Move ↑"};const e=n.parentNode.parentNode.parentNode.parentNode.querySelector("h2");e.parentNode?.appendChild(i)}}).observe(document.body,{childList:!0,subtree:!0}),function(...e){(0,console.log)(...e)}(`%c${w}%c (${y}) userscript has loaded!`,"color: cornflowerblue;","")})();
diff --git a/docs/CONTRIBUTING.md b/docs/CONTRIBUTING.md
index 68d2dcb..e502aea 100644
--- a/docs/CONTRIBUTING.md
+++ b/docs/CONTRIBUTING.md
@@ -53,15 +53,19 @@
Thank you for wanting to contribute to the userscript "Blue Marble"! It means a lot to me that someone likes my project enough to want to help it grow. If you haven't already done so, consider joining our Discord. You can ask questions about the userscript there and receive feedback. You can also visit the official Blue Marble website for more information.
Note: If you are using AI, and you want to tell the AI how the codebase files are related to each-other, go to the Class diagram of relationships for Blue Marble diagram in the chart section of this file. Copy the chart, and give it to the AI.
+
+ Note: If you are contributing to the documentation of this project, make your fork from the documentation branch. If you are contributing to the code/programming of this project, make your fork from the code branch. If you fork main, and make a PR from main -> main your PR might be rejected. This is because main is not up-to-date, and your changes might conflict with up-to-date changes.
Summary
I don't want to waste your time, so double check with me before starting a big change like adding a new feature. For example, imagine you spend 50 hours making a bot that automatically places pixels, then your pull request was rejected because a bot that automatically places pixles does not align with the "Mission" of Blue Marble. That would be sad :(
-
Follow the style of the project. E.g., if all overlays are made by calling `Overlay()`, and you want to make a new overlay, you should probably call `Overlay()` as well.
+
Follow the style of the project. E.g., if all overlays are made by calling Overlay(), and you want to make a new overlay, you should probably call Overlay() as well.
Don't fork the main branch! Fork either code or documentation.
+
If you are adding a new feature, and it is feasable to stick your feature inside a function, then use a function. This will make your code conflict less with other people's code. Make your code modular.
@@ -79,7 +83,14 @@
What Can I Contribute?
Programming
- Most of the work to be done in this userscript is related to programming. It is helpful to have a background in programming, but not required. If you are looking to learn JavaScript and its syntax, check out this roadmap for learning JavaScript. We strongly recommend that you understand functions, methods, classes, and Object-Oriented-Programming if you plan to implement a brand new feature. More technical knowledge like method chaining and lambda expressions are useful but not required. You can find the documentation for Blue Marble here.
+ Most of the work to be done in this userscript is related to programming. It is helpful to have a background in programming, but not required. If you are looking to learn JavaScript and its syntax, check out this roadmap for learning JavaScript. We strongly recommend that you understand functions, methods, classes, and Object-Oriented-Programming if you plan to implement a brand new feature. More technical knowledge like method chaining and lambda expressions are useful but not required. You can find the documentation for Blue Marble here. Make your code modular when possible. In other words, you should "blackbox" your code by putting it in a function when possible. For example, if you are adding a color filter to remove colors from being displayed on the template, the function should pass in the template information and tile information, and output the filtered template/tile information. This way, other people's code can't interfere with the color filter. For example:
+
+
+
The template image is generated and the tile information is retrieved.
+
The color filter function is passed in the template image and the tile information. The color filter overrides the template image with the filtered colors, and outputs that as the template image.
+
The pixel counter function is passed in the modified template image and the tile information, and outputs the pixel count.
+
The modified template image and the tile information is used to render the template.
If your template still does not show, try clicking the "Enable" button.
@@ -222,7 +223,11 @@
Transparent Pixels
- Templates for Blue Marble work slightly different from normal. Since there is a "Transparent" color, and transparent pixels in templates are typically ignored, your template should have a custom color to signify "Transparent" colored pixels. If a specific pixel can be any color, it should be transparent in the template. If a specific pixel should be "Transparent" color, it should have the #deface hex color. Any #deface colored pixel in your template will be interpereted as the "Transparent" color. Any transparent colored pixel in your template will be interpereted as ignored.
+ Templates for Blue Marble work slightly different from normal. Since there is a "Transparent" color, and transparent pixels in templates are typically ignored, your template should have a custom color to signify "Transparent" colored pixels.
+
+
If you want a specific pixel to be any color, it should be transparent in your template.
+
If you want a specific pixel to be the "Transparent" color on the Wplace palette, it should have the #deface hex color.
+
Coordinates
@@ -234,7 +239,7 @@
Template Coordinates
- The template is aligned from the top left corner of the template. You can auto-fill this position using the "pin" icon next to the coordinate input boxes.
+ The template is aligned from the top left corner of the template. You can auto-fill this position using the "pin" (also called "waypoint") icon next to the coordinate input boxes.
@@ -267,6 +272,12 @@
How do I hide the overlay?
A: Turn the userscript off and refresh the page.
+
How do I tell colors apart?
+
A: Find the color in the color filter list. Click the checkbox to turn the color on or off. If you want to work on only one color at a time (recommended), then click "Disable All" in the color filter. Finally, enable the checkbox next to the color you want to place. This way, only one color on your template will appear at a time.
+
+
How do get the color of a pixel?
+
A: Use the eyedropper in the palette menu of wplace. If your template colors match the wplace palette, you can select the template pixel dot to get the template's color for that pixel.
+
Why do game notifications appear on top of the overlay?
A: Game notifications only appear when they need immediate attention. Therefore, they have priority over the overlay (which typically needs no attention).
diff --git a/src/templateManager.js b/src/templateManager.js
index c103904..9bdfc8e 100644
--- a/src/templateManager.js
+++ b/src/templateManager.js
@@ -448,7 +448,6 @@ export default class TemplateManager {
// If this pixel is NOT the center pixel, then skip the pixel
if ((x % this.drawMult) !== 1 || (y % this.drawMult) !== 1) { continue; }
-
const idx = (y * tempW + x) * 4;
const r = data[idx];
const g = data[idx + 1];