diff --git a/dist/BlueMarble.user.css b/dist/BlueMarble.user.css index 15e73b6..4678111 100644 --- a/dist/BlueMarble.user.css +++ b/dist/BlueMarble.user.css @@ -1 +1 @@ -#bm-p{position:fixed;background-color:#153063e6;color:#fff;padding:10px;border-radius:8px;z-index:9000}div#bm-p{font-family:Roboto Mono,Courier New,Monaco,DejaVu Sans Mono,monospace,Arial;letter-spacing:.05em}#bm-k{margin-bottom:.5em;background:url('data:image/svg+xml;utf8,') repeat;cursor:grab;width:100%;height:1em}#bm-k.dragging{cursor:grabbing}#bm-b{margin-bottom:.5em}#bm-p img{display:inline-block;height:2.5em;margin-right:1ch;vertical-align:middle}#bm-p h1{display:inline-block;font-size:x-large;font-weight:700;vertical-align:middle}#bm-3 input[type=checkbox]{vertical-align:middle;margin-right:.5ch}#bm-3 label{margin-right:.5ch}.bm-s{border:white 1px solid;height:1.5em;width:1.5em;margin-top:2px;text-align:center;line-height:1em;padding:0!important}#bm-h{vertical-align:middle}#bm-h svg{width:50%;margin:0 auto;fill:#111}div:has(>#bm-7){display:flex;gap:.5ch}#bm-8 svg,#bm-button-template svg{height:1em;margin:2px auto 0;text-align:center;line-height:1em;vertical-align:bottom}#bm-c input[type=number]{appearance:auto;-moz-appearance:textfield;width:5.5ch;margin-left:1ch;background-color:#0003;padding:0 .5ch;font-size:small}#bm-c input[type=number]::-webkit-outer-spin-button,#bm-c input[type=number]::-webkit-inner-spin-button{-webkit-appearance:none;margin:0}#bm-0{display:flex;flex-direction:row;flex-wrap:wrap;align-content:center;justify-content:center;align-items:center;gap:1ch}div:has(>#bm-2)>button{width:100%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}#bm-e{font-size:small;background-color:#0003;padding:0 .5ch;height:3.75em;width:100%}#bm-1{display:flex;justify-content:space-between}#bm-p small{font-size:x-small;color:#d3d3d3}#bm-4,#bm-3,#bm-c,#bm-0,div:has(>#bm-2),#bm-e{margin-top:.5em}#bm-p button{background-color:#144eb9;border-radius:1em;padding:0 .75ch}#bm-p button:hover,#bm-p button:focus-visible{background-color:#1061e5}#bm-p button:active,#bm-p button:disabled{background-color:#2e97ff}#bm-p button:disabled{text-decoration:line-through} +#bm-p{position:fixed;background-color:#153063e6;color:#fff;padding:10px;border-radius:8px;z-index:9000}div#bm-p{font-family:Roboto Mono,Courier New,Monaco,DejaVu Sans Mono,monospace,Arial;letter-spacing:.05em}#bm-k{margin-bottom:.5em;background:url('data:image/svg+xml;utf8,') repeat;cursor:grab;width:100%;height:1em}#bm-k.dragging{cursor:grabbing}#bm-b{margin-bottom:.5em}#bm-p img{display:inline-block;height:2.5em;margin-right:1ch;vertical-align:middle}#bm-p h1{display:inline-block;font-size:x-large;font-weight:700;vertical-align:middle}#bm-3 input[type=checkbox]{vertical-align:middle;margin-right:.5ch}#bm-3 label{margin-right:.5ch}.bm-t{border:white 1px solid;height:1.5em;width:1.5em;margin-top:2px;text-align:center;line-height:1em;padding:0!important}#bm-h{vertical-align:middle}#bm-h svg{width:50%;margin:0 auto;fill:#111}div:has(>#bm-7){display:flex;gap:.5ch}#bm-8 svg,#bm-button-template svg{height:1em;margin:2px auto 0;text-align:center;line-height:1em;vertical-align:bottom}#bm-c input[type=number]{appearance:auto;-moz-appearance:textfield;width:5.5ch;margin-left:1ch;background-color:#0003;padding:0 .5ch;font-size:small}#bm-c input[type=number]::-webkit-outer-spin-button,#bm-c input[type=number]::-webkit-inner-spin-button{-webkit-appearance:none;margin:0}#bm-0{display:flex;flex-direction:row;flex-wrap:wrap;align-content:center;justify-content:center;align-items:center;gap:1ch}div:has(>#bm-2)>button{width:100%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}#bm-e{font-size:small;background-color:#0003;padding:0 .5ch;height:3.75em;width:100%}#bm-1{display:flex;justify-content:space-between}#bm-p small{font-size:x-small;color:#d3d3d3}#bm-4,#bm-3,#bm-c,#bm-0,div:has(>#bm-2),#bm-e{margin-top:.5em}#bm-p button{background-color:#144eb9;border-radius:1em;padding:0 .75ch}#bm-p button:hover,#bm-p button:focus-visible{background-color:#1061e5}#bm-p button:active,#bm-p button:disabled{background-color:#2e97ff}#bm-p button:disabled{text-decoration:line-through} diff --git a/dist/BlueMarble.user.css.map.json b/dist/BlueMarble.user.css.map.json index cc6db83..667660c 100644 --- a/dist/BlueMarble.user.css.map.json +++ b/dist/BlueMarble.user.css.map.json @@ -26,6 +26,7 @@ "bm-input-py": "bm-o", "bm-overlay": "bm-p", "bm-cStyle": "bm-q", - "bm-name": "bm-r", - "bm-help": "bm-s" + "bm-canvas": "bm-r", + "bm-name": "bm-s", + "bm-help": "bm-t" } \ No newline at end of file diff --git a/dist/BlueMarble.user.js b/dist/BlueMarble.user.js index defbbca..39ef94a 100644 --- a/dist/BlueMarble.user.js +++ b/dist/BlueMarble.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @name Blue Marble // @namespace https://github.com/SwingTheVine/ -// @version 0.60.14 +// @version 0.61.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 @@ -20,4 +20,4 @@ // Wplace --> https://wplace.live // License --> https://www.mozilla.org/en-US/MPL/2.0/ -(()=>{var t,e,n=t=>{throw TypeError(t)},s=(t,e,s)=>(((t,e)=>{e.has(t)||n("Cannot access private method")})(t,e),s);t=new WeakSet,e=function(t,e={},n={}){const s=document.createElement(t);this.t?(this.i.appendChild(s),this.o.push(this.i),this.i=s):(this.t=s,this.i=s);for(const[t,n]of Object.entries(e))s[t]=n;for(const[t,e]of Object.entries(n))s[t]=e;return s};var i=GM_info.script.name.toString(),o=GM_info.script.version.toString();function a(t){const e=document.createElement("script");e.setAttribute("bm-r",i),e.setAttribute("bm-q","color: cornflowerblue;"),e.textContent=`(${t})();`,document.documentElement.appendChild(e),e.remove()}a(()=>{const t=document.currentScript,e=t?.getAttribute("bm-r")||"Blue Marble",n=t?.getAttribute("bm-q")||"",s=window.fetch;window.fetch=async function(...t){const i=await s.apply(this,t),o=i.clone();if((o.headers.get("content-type")||"").includes("application/json")){let s=(t[0]instanceof Request?t[0]?.url:t[0])||"ignore";console.log(`%c${e}%c: Sending JSON message about endpoint "${s}"`,n,""),o.json().then(t=>{window.postMessage({source:"blue-marble",endpoint:s,jsonData:t},"*")}).catch(t=>{console.error(`%c${e}%c: Failed to parse JSON: `,n,"",t)})}return i}}),a(()=>{const t=document.currentScript,e=(t?.getAttribute("bm-r"),t?.getAttribute("bm-q"),maplibregl.Map);maplibregl.Map=function(...t){const n=new e(...t);return window.__bm_interceptedMap,n}});var r=GM_getResourceText("CSS-BM-File");GM_addStyle(r);var c=document.createElement("link");c.href="https://fonts.googleapis.com/css2?family=Roboto+Mono:ital,wght@0,100..700;1,100..700&display=swap",c.rel="preload",c.as="style",c.onload=function(){this.onload=null,this.rel="stylesheet"},document.head.appendChild(c),new class{constructor(){this.l=null,this.h=null,this.u="#bm-9"}m(t){return this.h=t,this.l=new MutationObserver(t=>{for(const e of t)for(const t of e.addedNodes)t instanceof HTMLElement&&t.matches?.(this.u)}),this}p(){return this.l}observe(t,e=!1,n=!1){t.observe(this.h,{childList:e,subtree:n})}};var l=new class{constructor(e,s){var i,o;i=this,(o=t).has(i)?n("Cannot add the same private member more than once"):o instanceof WeakSet?o.add(i):o.set(i,undefined),this.name=e,this.version=s,this.v=null,this.M="bm-e",this.t=null,this.i=null,this.o=[]}$(t){this.v=t}C(){return this.o.length>0&&(this.i=this.o.pop()),this}S(t){t.appendChild(this.t),this.t=null,this.i=null,this.o=[]}T(n={},i=()=>{}){return i(this,s(this,t,e).call(this,"div",{},n)),this}N(n={},i=()=>{}){return i(this,s(this,t,e).call(this,"p",{},n)),this}k(n={},i=()=>{}){return i(this,s(this,t,e).call(this,"small",{},n)),this}I(n={},i=()=>{}){return i(this,s(this,t,e).call(this,"img",{},n)),this}L(n,i={},o=()=>{}){return o(this,s(this,t,e).call(this,"h"+n,{},i)),this}B(n={},i=()=>{}){return i(this,s(this,t,e).call(this,"hr",{},n)),this}D(n={},i=()=>{}){return i(this,s(this,t,e).call(this,"br",{},n)),this}H(n={},i=()=>{}){const o=s(this,t,e).call(this,"label",{textContent:n.textContent??""});delete n.textContent;const a=s(this,t,e).call(this,"input",{type:"checkbox"},n);return o.insertBefore(a,o.firstChild),this.C(),i(this,o,a),this}O(n={},i=()=>{}){return i(this,s(this,t,e).call(this,"button",{},n)),this}R(n={},i=()=>{}){const o=n.title??n.textContent??"Help: No info";delete n.textContent,n.title=`Help: ${o}`;const a={textContent:"?",className:"bm-s",onclick:()=>{this.P(this.M,o)}};return i(this,s(this,t,e).call(this,"button",a,n)),this}U(n={},i=()=>{}){return i(this,s(this,t,e).call(this,"input",{},n)),this}j(n={},i=()=>{}){const o=n.textContent??"";delete n.textContent;const a=s(this,t,e).call(this,"div"),r=s(this,t,e).call(this,"input",{type:"file",style:"display: none;"},n);this.C();const c=s(this,t,e).call(this,"button",{textContent:o});return this.C(),this.C(),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=o}),i(this,a,r,c),this}_(n={},i=()=>{}){return i(this,s(this,t,e).call(this,"textarea",{},n)),this}P(t,e,n=!1){const s=document.getElementById(t.replace(/^#/,""));s&&(s instanceof HTMLInputElement?s.value=e:n?s.textContent=e:s.innerHTML=e)}F(t,e){let n,s=!1,i=0;t=document.querySelector("#"==t?.[0]?t:"#"+t),e=document.querySelector("#"==e?.[0]?e:"#"+e),t&&e?(e.addEventListener("mousedown",function(o){s=!0,n=o.clientX-t.getBoundingClientRect().left,i=o.clientY-t.getBoundingClientRect().top,document.body.style.userSelect="none",e.classList.add("dragging")}),e.addEventListener("touchstart",function(o){s=!0;const a=o?.touches?.[0];a&&(n=a.clientX-t.getBoundingClientRect().left,i=a.clientY-t.getBoundingClientRect().top,document.body.style.userSelect="none",e.classList.add("dragging"))},{passive:!1}),document.addEventListener("mousemove",function(e){s&&(t.style.left=e.clientX-n+"px",t.style.top=e.clientY-i+"px",t.style.right="")}),document.addEventListener("touchmove",function(e){if(s){const s=e?.touches?.[0];if(!s)return;t.style.left=s.clientX-n+"px",t.style.top=s.clientY-i+"px",e.preventDefault()}},{passive:!1}),document.addEventListener("mouseup",function(){s=!1,document.body.style.userSelect="",e.classList.remove("dragging")}),document.addEventListener("touchend",function(){s=!1,document.body.style.userSelect="",e.classList.remove("dragging")}),document.addEventListener("touchcancel",function(){s=!1,document.body.style.userSelect="",e.classList.remove("dragging")})):this.G(`Can not drag! ${t?"":"moveMe"} ${t||e?"":"and "}${e?"":"iMoveThings "}was not found!`)}W(t){(0,console.info)(`${this.name}: ${t}`),this.P(this.M,"Status: "+t,!0)}G(t){(0,console.error)(`${this.name}: ${t}`),this.P(this.M,"Error: "+t,!0)}}(i,o),h=new class{constructor(){this.X=null,this.Y="bm-W",this.q="div#map canvas.maplibregl-canvas",this.V=window.__bm_interceptedMap,this.J=this.J.bind(this),this.Z=this.Z.bind(this),this.A=this.A.bind(this),this.K=null,this.state=""}tt(){if(document.body.contains(this.X))return this.X;document.getElementById(this.Y)?.remove();const t=document.querySelector(this.q),e=document.createElement("canvas");return e.id=this.Y,e.className="maplibregl-canvas",e.style.position="absolute",e.style.top="0",e.style.left="0",e.style.height=t?.style?.height,e.style.width=t?.style?.width,e.style.zIndex="8999",e.style.pointerEvents="none",t?.parentElement?.appendChild(e),this.X=e,window.addEventListener("move",this.J),window.addEventListener("zoom",this.A),window.addEventListener("resize",this.Z),this.X}et(t){this.K=t,this.state="file";const e=URL.createObjectURL(t);window.open(e,"_blank"),setTimeout(()=>URL.revokeObjectURL(e),1e4)}nt(){const t=this.tt(this.Y)?.getContext("2d");t&&(t.fillStyle="red",t.fillRect(10,10,100,100))}J(){this.nt(),console.log(this.V)}A(){this.nt()}Z(){const t=document.querySelector(this.q),e=this.tt();e&&t&&(e.style.height=t.style.height,e.style.width=t.style.width,e.height=t.height,e.width=t.width,this.nt())}},d=new class{constructor(){this.st=!1,this.it=[]}ot(t){window.addEventListener("message",e=>{const n=e.data,s=n.jsonData;if(!n||"blue-marble"!==n.source)return;const i=n.endpoint.split("?")[0].split("/").filter(t=>t&&isNaN(Number(t))).pop();switch(console.log(`%cBlue Marble%c: Recieved message about "${i}"`,"color: cornflowerblue;",""),i){case"me":if(s.status&&"2"!=s.status?.toString()[0])return void t.G("The game is down!\nCould not fetch userdata.");const e=Math.ceil(Math.pow(Math.floor(s.level)*Math.pow(30,.65),1/.65)-s.pixelsPainted);t.P("bm-j",`Username: ${function(t){const e=document.createElement("div");return e.textContent=t,e.innerHTML}(s.name)}`),t.P("bm-f",`Droplets: ${(new Intl.NumberFormat).format(s.droplets)}`),t.P("bm-a",`Next level in ${(new Intl.NumberFormat).format(e)} pixel${1==e?"":"s"}`);break;case"pixel":const i=n.endpoint.split("?")[0].split("/").filter(t=>t&&!isNaN(Number(t))),r=new URLSearchParams(n.endpoint.split("?")[1]),c=[r.get("x"),r.get("y")];if(this.it.length&&(!i.length||!c.length))return void t.G("Coordinates are malformed!\nDid you try clicking the canvas first?");this.it=[...i,...c];const l=(o=i,a=c,[parseInt(o[0])%4*1e3+parseInt(a[0]),parseInt(o[1])%4*1e3+parseInt(a[1])]),h=document.querySelectorAll("span");for(const t of h)if(t.textContent.trim().includes(`${l[0]}, ${l[1]}`)){let e=document.querySelector("#bm-9");const n=`(Tl X: ${i[0]}, Tl Y: ${i[1]}, Px X: ${c[0]}, Px Y: ${c[1]})`;e?e.textContent=n:(e=document.createElement("span"),e.id="bm-9",e.textContent=n,e.style="margin-left: calc(var(--spacing)*3); font-size: small;",t.parentNode.parentNode.parentNode.insertAdjacentElement("afterend",e))}break;case"robots":this.st="false"==s.userscript?.toString().toLowerCase();break}var o,a})}};l.$(d),l.T({id:"bm-p",style:"top: 10px; right: 75px;"}).T({id:"bm-b"}).T({id:"bm-k"}).C().I({alt:"Blue Marble Icon",src:"https://raw.githubusercontent.com/SwingTheVine/Wplace-BlueMarble/main/dist/assets/Favicon.png"}).C().L(1,{textContent:i}).C().C().B().C().T({id:"bm-4"}).N({id:"bm-j",textContent:"Username:"}).C().N({id:"bm-f",textContent:"Droplets:"}).C().N({id:"bm-a",textContent:"Next level in..."}).C().C().B().C().T({id:"bm-3"}).H({id:"bm-g",textContent:"Stealth",checked:!0}).C().R({title:"Waits for the website to make requests, instead of sending requests."}).C().D().C().H({id:"bm-6",textContent:"Possessed",checked:!0}).C().R({title:"Controls the website as if it were possessed."}).C().D().C().T({id:"bm-c"}).O({id:"bm-h",className:"bm-s",style:"margin-top: 0;",innerHTML:''},(t,e)=>{e.onclick=()=>{const e=t.v?.it;e?.[0]?(t.P("bm-l",e?.[0]||""),t.P("bm-m",e?.[1]||""),t.P("bm-n",e?.[2]||""),t.P("bm-o",e?.[3]||"")):t.G("Coordinates are malformed! Did you try clicking on the canvas first?")}}).C().U({type:"number",id:"bm-l",placeholder:"Tl X",min:0,max:2047,step:1}).C().U({type:"number",id:"bm-m",placeholder:"Tl Y",min:0,max:2047,step:1}).C().U({type:"number",id:"bm-n",placeholder:"Px X",min:0,max:2047,step:1}).C().U({type:"number",id:"bm-o",placeholder:"Px Y",min:0,max:2047,step:1}).C().C().j({id:"bm-2",textContent:"Upload Template",accept:"image/png, image/jpeg, image/webp, image/bmp, image/gif"}).C().T({id:"bm-0"}).O({id:"bm-i",textContent:"Enable"},(t,e)=>{e.onclick=()=>{const e=document.querySelector("#bm-2");e?.files[0]?(h.et(e.files[0]),h.nt(),console.log(h.X),t.W("Drew to canvas!")):t.G("No file selected!")}}).C().O({id:"bm-d",textContent:"Disable"}).C().C()._({id:l.M,placeholder:`Status: Sleeping...\nVersion: ${o}`,readOnly:!0}).C().T({id:"bm-1"}).T().O({id:"bm-7",className:"bm-s",textContent:"✈"}).C().O({id:"bm-8",className:"bm-s",innerHTML:''}).C().O({id:"bm-5",className:"bm-s",innerHTML:"🖌"}).C().C().k({textContent:"Made by SwingTheVine",style:"margin-top: auto;"}).C().C().C().S(document.body),l.F("#bm-p","#bm-k"),d.ot(l),function(...t){(0,console.log)(...t)}(`%c${i}%c (${o}) userscript has loaded!`,"color: cornflowerblue;","")})(); \ No newline at end of file +(()=>{var t,e,n=t=>{throw TypeError(t)},s=(t,e,s)=>(((t,e)=>{e.has(t)||n("Cannot access private method")})(t,e),s);t=new WeakSet,e=function(t,e={},n={}){const s=document.createElement(t);this.t?(this.i.appendChild(s),this.o.push(this.i),this.i=s):(this.t=s,this.i=s);for(const[t,n]of Object.entries(e))s[t]=n;for(const[t,e]of Object.entries(n))s[t]=e;return s};var i=GM_info.script.name.toString(),o=GM_info.script.version.toString();function a(t){const e=document.createElement("script");e.setAttribute("bm-s",i),e.setAttribute("bm-q","color: cornflowerblue;"),e.textContent=`(${t})();`,document.documentElement.appendChild(e),e.remove()}a(()=>{const t=document.currentScript,e=(t?.getAttribute("bm-s"),t?.getAttribute("bm-q"),window.fetch);window.fetch=async function(...t){const n=await e.apply(this,t),s=n.clone();if((s.headers.get("content-type")||"").includes("application/json")){let e=(t[0]instanceof Request?t[0]?.url:t[0])||"ignore";s.json().then(t=>{window.postMessage({source:"blue-marble",endpoint:e,jsonData:t},"*")}).catch(t=>{})}return n}}),a(()=>{const t=document.currentScript,e=(t?.getAttribute("bm-s"),t?.getAttribute("bm-q"),maplibregl.Map);maplibregl.Map=function(...t){const n=new e(...t);return window.__bm_interceptedMap,n}});var r=GM_getResourceText("CSS-BM-File");GM_addStyle(r);var h=document.createElement("link");h.href="https://fonts.googleapis.com/css2?family=Roboto+Mono:ital,wght@0,100..700;1,100..700&display=swap",h.rel="preload",h.as="style",h.onload=function(){this.onload=null,this.rel="stylesheet"},document.head.appendChild(h),new class{constructor(){this.h=null,this.l=null,this.u="#bm-9"}m(t){return this.l=t,this.h=new MutationObserver(t=>{for(const e of t)for(const t of e.addedNodes)t instanceof HTMLElement&&t.matches?.(this.u)}),this}p(){return this.h}observe(t,e=!1,n=!1){t.observe(this.l,{childList:e,subtree:n})}};var c=new class{constructor(e,s){var i,o;i=this,(o=t).has(i)?n("Cannot add the same private member more than once"):o instanceof WeakSet?o.add(i):o.set(i,undefined),this.name=e,this.version=s,this.v=null,this.M="bm-e",this.t=null,this.i=null,this.o=[]}C(t){this.v=t}$(){return this.o.length>0&&(this.i=this.o.pop()),this}T(t){t.appendChild(this.t),this.t=null,this.i=null,this.o=[]}S(n={},i=()=>{}){return i(this,s(this,t,e).call(this,"div",{},n)),this}k(n={},i=()=>{}){return i(this,s(this,t,e).call(this,"p",{},n)),this}N(n={},i=()=>{}){return i(this,s(this,t,e).call(this,"small",{},n)),this}I(n={},i=()=>{}){return i(this,s(this,t,e).call(this,"img",{},n)),this}L(n,i={},o=()=>{}){return o(this,s(this,t,e).call(this,"h"+n,{},i)),this}D(n={},i=()=>{}){return i(this,s(this,t,e).call(this,"hr",{},n)),this}H(n={},i=()=>{}){return i(this,s(this,t,e).call(this,"br",{},n)),this}B(n={},i=()=>{}){const o=s(this,t,e).call(this,"label",{textContent:n.textContent??""});delete n.textContent;const a=s(this,t,e).call(this,"input",{type:"checkbox"},n);return o.insertBefore(a,o.firstChild),this.$(),i(this,o,a),this}R(n={},i=()=>{}){return i(this,s(this,t,e).call(this,"button",{},n)),this}O(n={},i=()=>{}){const o=n.title??n.textContent??"Help: No info";delete n.textContent,n.title=`Help: ${o}`;const a={textContent:"?",className:"bm-t",onclick:()=>{this.P(this.M,o)}};return i(this,s(this,t,e).call(this,"button",a,n)),this}U(n={},i=()=>{}){return i(this,s(this,t,e).call(this,"input",{},n)),this}j(n={},i=()=>{}){const o=n.textContent??"";delete n.textContent;const a=s(this,t,e).call(this,"div"),r=s(this,t,e).call(this,"input",{type:"file",style:"display: none;"},n);this.$();const h=s(this,t,e).call(this,"button",{textContent:o});return this.$(),this.$(),h.addEventListener("click",()=>{r.click()}),r.addEventListener("change",()=>{h.style.maxWidth=`${h.offsetWidth}px`,r.files.length>0?h.textContent=r.files[0].name:h.textContent=o}),i(this,a,r,h),this}_(n={},i=()=>{}){return i(this,s(this,t,e).call(this,"textarea",{},n)),this}P(t,e,n=!1){const s=document.getElementById(t.replace(/^#/,""));s&&(s instanceof HTMLInputElement?s.value=e:n?s.textContent=e:s.innerHTML=e)}G(t,e){let n,s=!1,i=0;t=document.querySelector("#"==t?.[0]?t:"#"+t),e=document.querySelector("#"==e?.[0]?e:"#"+e),t&&e?(e.addEventListener("mousedown",function(o){s=!0,n=o.clientX-t.getBoundingClientRect().left,i=o.clientY-t.getBoundingClientRect().top,document.body.style.userSelect="none",e.classList.add("dragging")}),e.addEventListener("touchstart",function(o){s=!0;const a=o?.touches?.[0];a&&(n=a.clientX-t.getBoundingClientRect().left,i=a.clientY-t.getBoundingClientRect().top,document.body.style.userSelect="none",e.classList.add("dragging"))},{passive:!1}),document.addEventListener("mousemove",function(e){s&&(t.style.left=e.clientX-n+"px",t.style.top=e.clientY-i+"px",t.style.right="")}),document.addEventListener("touchmove",function(e){if(s){const s=e?.touches?.[0];if(!s)return;t.style.left=s.clientX-n+"px",t.style.top=s.clientY-i+"px",e.preventDefault()}},{passive:!1}),document.addEventListener("mouseup",function(){s=!1,document.body.style.userSelect="",e.classList.remove("dragging")}),document.addEventListener("touchend",function(){s=!1,document.body.style.userSelect="",e.classList.remove("dragging")}),document.addEventListener("touchcancel",function(){s=!1,document.body.style.userSelect="",e.classList.remove("dragging")})):this.W(`Can not drag! ${t?"":"moveMe"} ${t||e?"":"and "}${e?"":"iMoveThings "}was not found!`)}X(t){(0,console.info)(`${this.name}: ${t}`),this.P(this.M,"Status: "+t,!0)}W(t){(0,console.error)(`${this.name}: ${t}`),this.P(this.M,"Error: "+t,!0)}}(i,o),l=new class{constructor(){this.Y=null,this.q="bm-r",this.F="div#map canvas.maplibregl-canvas",this.V=window.__bm_interceptedMap,this.Z=this.Z.bind(this),this.A=this.A.bind(this),this.J=this.J.bind(this),this.K=null,this.state=""}tt(){if(document.body.contains(this.Y))return this.Y;document.getElementById(this.q)?.remove();const t=document.querySelector(this.F),e=document.createElement("canvas");return e.id=this.q,e.className="maplibregl-canvas",e.style.position="absolute",e.style.top="0",e.style.left="0",e.style.height=t?.style?.height,e.style.width=t?.style?.width,e.style.zIndex="8999",e.style.pointerEvents="none",t?.parentElement?.appendChild(e),this.Y=e,window.addEventListener("move",this.Z),window.addEventListener("zoom",this.J),window.addEventListener("resize",this.A),this.Y}et(t){this.K=t,this.state="file";const e=URL.createObjectURL(t);window.open(e,"_blank"),setTimeout(()=>URL.revokeObjectURL(e),1e4)}nt(){const t=this.tt(this.q)?.getContext("2d");t&&(t.fillStyle="red",t.fillRect(10,10,100,100))}Z(){this.nt()}J(){this.nt()}A(){const t=document.querySelector(this.F),e=this.tt();e&&t&&(e.style.height=t.style.height,e.style.width=t.style.width,e.height=t.height,e.width=t.width,this.nt())}},d=new class{constructor(){this.st=!1,this.it=[]}ot(t){window.addEventListener("message",e=>{const n=e.data,s=n.jsonData;var i,o;if(n&&"blue-marble"===n.source)switch(n.endpoint.split("?")[0].split("/").filter(t=>t&&isNaN(Number(t))).pop()){case"me":if(s.status&&"2"!=s.status?.toString()[0])return void t.W("The game is down!\nCould not fetch userdata.");const e=Math.ceil(Math.pow(Math.floor(s.level)*Math.pow(30,.65),1/.65)-s.pixelsPainted);t.P("bm-j",`Username: ${function(t){const e=document.createElement("div");return e.textContent=t,e.innerHTML}(s.name)}`),t.P("bm-f",`Droplets: ${(new Intl.NumberFormat).format(s.droplets)}`),t.P("bm-a",`Next level in ${(new Intl.NumberFormat).format(e)} pixel${1==e?"":"s"}`);break;case"pixel":const a=n.endpoint.split("?")[0].split("/").filter(t=>t&&!isNaN(Number(t))),r=new URLSearchParams(n.endpoint.split("?")[1]),h=[r.get("x"),r.get("y")];if(this.it.length&&(!a.length||!h.length))return void t.W("Coordinates are malformed!\nDid you try clicking the canvas first?");this.it=[...a,...h];const c=(i=a,o=h,[parseInt(i[0])%4*1e3+parseInt(o[0]),parseInt(i[1])%4*1e3+parseInt(o[1])]),l=document.querySelectorAll("span");for(const t of l)if(t.textContent.trim().includes(`${c[0]}, ${c[1]}`)){let e=document.querySelector("#bm-9");const n=`(Tl X: ${a[0]}, Tl Y: ${a[1]}, Px X: ${h[0]}, Px Y: ${h[1]})`;e?e.textContent=n:(e=document.createElement("span"),e.id="bm-9",e.textContent=n,e.style="margin-left: calc(var(--spacing)*3); font-size: small;",t.parentNode.parentNode.parentNode.insertAdjacentElement("afterend",e))}break;case"robots":this.st="false"==s.userscript?.toString().toLowerCase()}})}};c.C(d),c.S({id:"bm-p",style:"top: 10px; right: 75px;"}).S({id:"bm-b"}).S({id:"bm-k"}).$().I({alt:"Blue Marble Icon",src:"https://raw.githubusercontent.com/SwingTheVine/Wplace-BlueMarble/main/dist/assets/Favicon.png"}).$().L(1,{textContent:i}).$().$().D().$().S({id:"bm-4"}).k({id:"bm-j",textContent:"Username:"}).$().k({id:"bm-f",textContent:"Droplets:"}).$().k({id:"bm-a",textContent:"Next level in..."}).$().$().D().$().S({id:"bm-3"}).B({id:"bm-g",textContent:"Stealth",checked:!0}).$().O({title:"Waits for the website to make requests, instead of sending requests."}).$().H().$().B({id:"bm-6",textContent:"Possessed",checked:!0}).$().O({title:"Controls the website as if it were possessed."}).$().H().$().S({id:"bm-c"}).R({id:"bm-h",className:"bm-t",style:"margin-top: 0;",innerHTML:''},(t,e)=>{e.onclick=()=>{const e=t.v?.it;e?.[0]?(t.P("bm-l",e?.[0]||""),t.P("bm-m",e?.[1]||""),t.P("bm-n",e?.[2]||""),t.P("bm-o",e?.[3]||"")):t.W("Coordinates are malformed! Did you try clicking on the canvas first?")}}).$().U({type:"number",id:"bm-l",placeholder:"Tl X",min:0,max:2047,step:1}).$().U({type:"number",id:"bm-m",placeholder:"Tl Y",min:0,max:2047,step:1}).$().U({type:"number",id:"bm-n",placeholder:"Px X",min:0,max:2047,step:1}).$().U({type:"number",id:"bm-o",placeholder:"Px Y",min:0,max:2047,step:1}).$().$().j({id:"bm-2",textContent:"Upload Template",accept:"image/png, image/jpeg, image/webp, image/bmp, image/gif"}).$().S({id:"bm-0"}).R({id:"bm-i",textContent:"Enable"},(t,e)=>{e.onclick=()=>{const e=document.querySelector("#bm-2");e?.files[0]?(l.et(e.files[0]),l.nt(),t.X("Drew to canvas!")):t.W("No file selected!")}}).$().R({id:"bm-d",textContent:"Disable"}).$().$()._({id:c.M,placeholder:`Status: Sleeping...\nVersion: ${o}`,readOnly:!0}).$().S({id:"bm-1"}).S().R({id:"bm-7",className:"bm-t",textContent:"✈"}).$().R({id:"bm-8",className:"bm-t",innerHTML:''}).$().R({id:"bm-5",className:"bm-t",innerHTML:"🖌"}).$().$().N({textContent:"Made by SwingTheVine",style:"margin-top: auto;"}).$().$().$().T(document.body),c.G("#bm-p","#bm-k"),d.ot(c),function(...t){(0,console.log)(...t)}(`%c${i}%c (${o}) userscript has loaded!`,"color: cornflowerblue;","")})(); \ No newline at end of file diff --git a/docs/README.md b/docs/README.md index f4e834e..134fd90 100644 --- a/docs/README.md +++ b/docs/README.md @@ -30,7 +30,7 @@