Blue Marble CN

【汉化版】Blue Marble 用户脚本,用于增强 Wplace.live 体验。本脚本为 Blue Marble 的汉化分支,保留原作者 SwingTheVine 信息,遵循 MPL-2.0 协议。

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Blue Marble CN
// @namespace    https://github.com/SwingTheVine/
// @version      0.85.0-CN
// @description  【汉化版】Blue Marble 用户脚本,用于增强 Wplace.live 体验。本脚本为 Blue Marble 的汉化分支,保留原作者 SwingTheVine 信息,遵循 MPL-2.0 协议。
// @author       SwingTheVine
// @translator   Muyue (汉化)
// @license      MPL-2.0
// @supportURL   https://discord.gg/tpeBPy46hf
// @homepageURL  https://github.com/MuyueHan/BlueMarble-CN
// @icon         https://raw.githubusercontent.com/MuyueHan/BlueMarble-CN/main/dist/assets/Favicon.png
// @match        https://wplace.live/*
// @grant        GM_getResourceText
// @grant        GM_addStyle
// @grant        GM.setValue
// @grant        GM_getValue
// @grant        GM_xmlhttpRequest
// @connect      telemetry.thebluecorner.net
// @resource     CSS-BM-File https://raw.githubusercontent.com/MuyueHan/BlueMarble-CN/main/dist/BlueMarbleCN.user.css
// ==/UserScript==

// 汉化分支说明:
// 本脚本在原作者 SwingTheVine 的 Blue Marble 基础上进行汉化。
// 原版仓库: https://github.com/SwingTheVine/Wplace-BlueMarble
// 汉化仓库: https://github.com/Rckmuyue/Wplace-BlueMarble-CN
// 许可证: Mozilla Public License Version 2.0
const cssContent='#bm-overlay,#bm-overlay-telemetry{position:fixed;background-color:#153063e6;color:#fff;padding:10px;border-radius:8px;z-index:9000;transition:all .3s ease,transform 0s;max-width:300px;width:auto;will-change:transform;backface-visibility:hidden;-webkit-backface-visibility:hidden;transform-style:preserve-3d;-webkit-transform-style:preserve-3d}#bm-contain-userinfo,#bm-overlay hr,#bm-overlay-telemetry hr,#bm-contain-automation,#bm-contain-buttons-action{transition:opacity .2s ease,height .2s ease}div#bm-overlay,div#bm-overlay-telemetry{font-family:Roboto Mono,Courier New,Monaco,DejaVu Sans Mono,monospace,Arial;letter-spacing:.05em}#bm-bar-drag,#bm-bar-drag-telemetry{margin-bottom:.5em;background:url(\'data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="5" height="5"><circle cx="3" cy="3" r="1.5" fill="CornflowerBlue" /></svg>\') repeat;cursor:grab;width:100%;height:1em}#bm-bar-drag.dragging,#bm-bar-drag-telemetry.dragging{cursor:grabbing}#bm-overlay:has(#bm-bar-drag.dragging),#bm-overlay-telemetry:has(#bm-bar-drag-telemetry.dragging){pointer-events:none;user-select:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none}#bm-bar-drag.dragging,#bm-bar-drag-telemetry.dragging{pointer-events:auto}#bm-contain-header,#bm-contain-header-telemetry{margin-bottom:.5em}#bm-contain-header[style*="text-align: center"],#bm-contain-header-telemetry[style*="text-align: center"]{display:flex;flex-direction:column;align-items:center;justify-content:center}#bm-overlay[style*="padding: 5px"],#bm-overlay-telemetry[style*="padding: 5px"]{width:auto!important;max-width:300px;min-width:200px}#bm-overlay img{display:inline-block;height:2.5em;margin-right:1ch;vertical-align:middle;transition:opacity .2s ease}#bm-contain-header[style*="text-align: center"] img{display:block;margin:0 auto}#bm-bar-drag,#bm-bar-drag-telemetry{transition:margin-bottom .2s ease}#bm-overlay h1,#bm-overlay-telemetry h1{display:inline-block;font-size:x-large;font-weight:700;vertical-align:middle}#bm-contain-automation input[type=checkbox]{vertical-align:middle;margin-right:.5ch}#bm-contain-automation label{margin-right:.5ch}.bm-help{border:white 1px solid;height:1.5em;width:1.5em;margin-top:2px;text-align:center;line-height:1em;padding:0!important}#bm-button-coords{vertical-align:middle}#bm-button-coords svg{width:50%;margin:0 auto;fill:#111}div:has(>#bm-button-teleport){display:flex;gap:.5ch}#bm-button-favorite svg,#bm-button-template svg{height:1em;margin:2px auto 0;text-align:center;line-height:1em;vertical-align:bottom}#bm-contain-coords input[type=number]{appearance:auto;-moz-appearance:textfield;width:5.5ch;margin-left:1ch;background-color:#0003;padding:0 .5ch;font-size:small}#bm-contain-coords input[type=number]::-webkit-outer-spin-button,#bm-contain-coords input[type=number]::-webkit-inner-spin-button{-webkit-appearance:none;margin:0}#bm-contain-buttons-template{display:flex;flex-direction:row;flex-wrap:wrap;align-content:center;justify-content:center;align-items:center;gap:1ch}div:has(>#bm-input-file-template)>button{width:100%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}#bm-input-file-template,input[type=file][id*=template]{display:none!important;visibility:hidden!important;position:absolute!important;left:-9999px!important;top:-9999px!important;width:0!important;height:0!important;opacity:0!important;z-index:-9999!important;pointer-events:none!important}#bm-output-status{font-size:small;background-color:#0003;padding:0 .5ch;height:3.75em;width:100%}#bm-contain-buttons-action{display:flex;justify-content:space-between}#bm-overlay small{font-size:x-small;color:#d3d3d3}#bm-contain-userinfo,#bm-contain-automation,#bm-contain-coords,#bm-contain-buttons-template,div:has(>#bm-input-file-template),#bm-output-status{margin-top:.5em}#bm-overlay button,#bm-overlay-telemetry button{background-color:#144eb9;border-radius:1em;padding:0 .75ch}#bm-overlay button:hover,#bm-overlay button:focus-visible,#bm-overlay-telemetry button:hover,#bm-overlay-telemetry button:focus-visible{background-color:#1061e5}#bm-overlay button:active,#bm-overlay-telemetry button:active #bm-overlay button:disabled,#bm-overlay-telemetry button:disabled{background-color:#2e97ff}#bm-overlay button:disabled,#bm-overlay-telemetry button:disabled{text-decoration:line-through}\n';GM_addStyle(cssContent),(()=>{var t,e,n=t=>{throw TypeError(t)},i=(t,e,i)=>e.has(t)?n("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,i),o=(t,e,i)=>(((t,e)=>{e.has(t)||n("Cannot access private method")})(t,e),i),r=class{constructor(e,n){i(this,t),this.name=e,this.version=n,this.t=null,this.i="bm-output-status",this.o=null,this.l=null,this.m=[]}u(t){this.t=t}h(){return this.m.length>0&&(this.l=this.m.pop()),this}p(t){t?.appendChild(this.o),this.o=null,this.l=null,this.m=[]}v(n={},i=()=>{}){return i(this,o(this,t,e).call(this,"div",{},n)),this}$(n={},i=()=>{}){return i(this,o(this,t,e).call(this,"p",{},n)),this}S(n={},i=()=>{}){return i(this,o(this,t,e).call(this,"small",{},n)),this}M(n={},i=()=>{}){return i(this,o(this,t,e).call(this,"img",{},n)),this}O(n,i={},r=()=>{}){return r(this,o(this,t,e).call(this,"h"+n,{},i)),this}k(n={},i=()=>{}){return i(this,o(this,t,e).call(this,"hr",{},n)),this}N(n={},i=()=>{}){return i(this,o(this,t,e).call(this,"br",{},n)),this}T(n={},i=()=>{}){const r=o(this,t,e).call(this,"label",{textContent:n.textContent??""});delete n.textContent;const a=o(this,t,e).call(this,"input",{type:"checkbox"},n);return r.insertBefore(a,r.firstChild),this.h(),i(this,r,a),this}C(n={},i=()=>{}){return i(this,o(this,t,e).call(this,"button",{},n)),this}B(n={},i=()=>{}){const r=n.title??n.textContent??"Help: No info";delete n.textContent,n.title=`Help: ${r}`;const a={textContent:"?",className:"bm-help",onclick:()=>{this.D(this.i,r)}};return i(this,o(this,t,e).call(this,"button",a,n)),this}I(n={},i=()=>{}){return i(this,o(this,t,e).call(this,"input",{},n)),this}L(n={},i=()=>{}){const r=n.textContent??"";delete n.textContent;const a=o(this,t,e).call(this,"div"),s=o(this,t,e).call(this,"input",{type:"file",style:"display: none !important; visibility: hidden !important; position: absolute !important; left: -9999px !important; width: 0 !important; height: 0 !important; opacity: 0 !important;"},n);this.h();const l=o(this,t,e).call(this,"button",{textContent:r});return this.h(),this.h(),s.setAttribute("tabindex","-1"),s.setAttribute("aria-hidden","true"),l.addEventListener("click",()=>{s.click()}),s.addEventListener("change",()=>{l.style.maxWidth=`${l.offsetWidth}px`,s.files.length>0?l.textContent=s.files[0].name:l.textContent=r}),i(this,a,s,l),this}G(n={},i=()=>{}){return i(this,o(this,t,e).call(this,"textarea",{},n)),this}D(t,e,n=!1){const i=document.getElementById(t.replace(/^#/,""));i&&(i instanceof HTMLInputElement?i.value=e:n?i.textContent=e:i.innerHTML=e)}j(t,e){let n,i=!1,o=0,r=null,a=0,s=0,l=0,m=0;if(t=document.querySelector("#"==t?.[0]?t:"#"+t),e=document.querySelector("#"==e?.[0]?e:"#"+e),!t||!e)return void this._(`Can not drag! ${t?"":"moveMe"} ${t||e?"":"and "}${e?"":"iMoveThings "}was not found!`);const c=()=>{if(i){const e=Math.abs(a-l),n=Math.abs(s-m);(e>.5||n>.5)&&(a=l,s=m,t.style.transform=`translate(${a}px, ${s}px)`,t.style.left="0px",t.style.top="0px",t.style.right=""),r=requestAnimationFrame(c)}};let u=null;const d=(d,b)=>{i=!0,u=t.getBoundingClientRect(),n=d-u.left,o=b-u.top;const h=window.getComputedStyle(t).transform;if(h&&"none"!==h){const t=new DOMMatrix(h);a=t.m41,s=t.m42}else a=u.left,s=u.top;l=a,m=s,document.body.style.userSelect="none",e.classList.add("dragging"),r&&cancelAnimationFrame(r),c()},b=()=>{i=!1,r&&(cancelAnimationFrame(r),r=null),document.body.style.userSelect="",e.classList.remove("dragging")};e.addEventListener("mousedown",function(t){t.preventDefault(),d(t.clientX,t.clientY)}),e.addEventListener("touchstart",function(t){const e=t?.touches?.[0];e&&(d(e.clientX,e.clientY),t.preventDefault())},{passive:!1}),document.addEventListener("mousemove",function(t){i&&u&&(l=t.clientX-n,m=t.clientY-o)},{passive:!0}),document.addEventListener("touchmove",function(t){if(i&&u){const e=t?.touches?.[0];if(!e)return;l=e.clientX-n,m=e.clientY-o,t.preventDefault()}},{passive:!1}),document.addEventListener("mouseup",b),document.addEventListener("touchend",b),document.addEventListener("touchcancel",b)}P(t){(0,console.info)(`${this.name}: ${t}`),this.D(this.i,"Status: "+t,!0)}_(t){(0,console.error)(`${this.name}: ${t}`),this.D(this.i,"Error: "+t,!0)}};function a(...t){(0,console.error)(...t)}function s(t,e){if(0===t)return e[0];let n="";const i=e.length;for(;t>0;)n=e[t%i]+n,t=Math.floor(t/i);return n}function l(t){let e="";for(let n=0;n<t.length;n++)e+=String.fromCharCode(t[n]);return btoa(e)}function m(t){const e=atob(t),n=new Uint8Array(e.length);for(let t=0;t<e.length;t++)n[t]=e.charCodeAt(t);return n}t=new WeakSet,e=function(t,e={},n={}){const i=document.createElement(t);this.o?(this.l?.appendChild(i),this.m.push(this.l),this.l=i):(this.o=i,this.l=i);for(const[t,n]of Object.entries(e))i[t]=n;for(const[t,e]of Object.entries(n))i[t]=e;return i};var c,u,d,b,h,p,g=[{id:0,premium:!1,name:"Transparent",rgb:[0,0,0]},{id:1,premium:!1,name:"Black",rgb:[0,0,0]},{id:2,premium:!1,name:"Dark Gray",rgb:[60,60,60]},{id:3,premium:!1,name:"Gray",rgb:[120,120,120]},{id:4,premium:!1,name:"Light Gray",rgb:[210,210,210]},{id:5,premium:!1,name:"White",rgb:[255,255,255]},{id:6,premium:!1,name:"Deep Red",rgb:[96,0,24]},{id:7,premium:!1,name:"Red",rgb:[237,28,36]},{id:8,premium:!1,name:"Orange",rgb:[255,127,39]},{id:9,premium:!1,name:"Gold",rgb:[246,170,9]},{id:10,premium:!1,name:"Yellow",rgb:[249,221,59]},{id:11,premium:!1,name:"Light Yellow",rgb:[255,250,188]},{id:12,premium:!1,name:"Dark Green",rgb:[14,185,104]},{id:13,premium:!1,name:"Green",rgb:[19,230,123]},{id:14,premium:!1,name:"Light Green",rgb:[135,255,94]},{id:15,premium:!1,name:"Dark Teal",rgb:[12,129,110]},{id:16,premium:!1,name:"Teal",rgb:[16,174,166]},{id:17,premium:!1,name:"Light Teal",rgb:[19,225,190]},{id:18,premium:!1,name:"Dark Blue",rgb:[40,80,158]},{id:19,premium:!1,name:"Blue",rgb:[64,147,228]},{id:20,premium:!1,name:"Cyan",rgb:[96,247,242]},{id:21,premium:!1,name:"Indigo",rgb:[107,80,246]},{id:22,premium:!1,name:"Light Indigo",rgb:[153,177,251]},{id:23,premium:!1,name:"Dark Purple",rgb:[120,12,153]},{id:24,premium:!1,name:"Purple",rgb:[170,56,185]},{id:25,premium:!1,name:"Light Purple",rgb:[224,159,249]},{id:26,premium:!1,name:"Dark Pink",rgb:[203,0,122]},{id:27,premium:!1,name:"Pink",rgb:[236,31,128]},{id:28,premium:!1,name:"Light Pink",rgb:[243,141,169]},{id:29,premium:!1,name:"Dark Brown",rgb:[104,70,52]},{id:30,premium:!1,name:"Brown",rgb:[149,104,42]},{id:31,premium:!1,name:"Beige",rgb:[248,178,119]},{id:32,premium:!0,name:"Medium Gray",rgb:[170,170,170]},{id:33,premium:!0,name:"Dark Red",rgb:[165,14,30]},{id:34,premium:!0,name:"Light Red",rgb:[250,128,114]},{id:35,premium:!0,name:"Dark Orange",rgb:[228,92,26]},{id:36,premium:!0,name:"Light Tan",rgb:[214,181,148]},{id:37,premium:!0,name:"Dark Goldenrod",rgb:[156,132,49]},{id:38,premium:!0,name:"Goldenrod",rgb:[197,173,49]},{id:39,premium:!0,name:"Light Goldenrod",rgb:[232,212,95]},{id:40,premium:!0,name:"Dark Olive",rgb:[74,107,58]},{id:41,premium:!0,name:"Olive",rgb:[90,148,74]},{id:42,premium:!0,name:"Light Olive",rgb:[132,197,115]},{id:43,premium:!0,name:"Dark Cyan",rgb:[15,121,159]},{id:44,premium:!0,name:"Light Cyan",rgb:[187,250,242]},{id:45,premium:!0,name:"Light Blue",rgb:[125,199,255]},{id:46,premium:!0,name:"Dark Indigo",rgb:[77,49,184]},{id:47,premium:!0,name:"Dark Slate Blue",rgb:[74,66,132]},{id:48,premium:!0,name:"Slate Blue",rgb:[122,113,196]},{id:49,premium:!0,name:"Light Slate Blue",rgb:[181,174,241]},{id:50,premium:!0,name:"Light Brown",rgb:[219,164,99]},{id:51,premium:!0,name:"Dark Beige",rgb:[209,128,81]},{id:52,premium:!0,name:"Light Beige",rgb:[255,197,165]},{id:53,premium:!0,name:"Dark Peach",rgb:[155,82,73]},{id:54,premium:!0,name:"Peach",rgb:[209,128,120]},{id:55,premium:!0,name:"Light Peach",rgb:[250,182,164]},{id:56,premium:!0,name:"Dark Tan",rgb:[123,99,82]},{id:57,premium:!0,name:"Tan",rgb:[156,132,107]},{id:58,premium:!0,name:"Dark Slate",rgb:[51,57,65]},{id:59,premium:!0,name:"Slate",rgb:[109,117,141]},{id:60,premium:!0,name:"Light Slate",rgb:[179,185,209]},{id:61,premium:!0,name:"Dark Stone",rgb:[109,100,63]},{id:62,premium:!0,name:"Stone",rgb:[148,140,107]},{id:63,premium:!0,name:"Light Stone",rgb:[205,197,158]}],f=class{constructor({displayName:t="My template",W:e=0,J:n="",url:i="",file:o=null,coords:r=null,R:a=null,X:s=1e3}={}){this.displayName=t,this.W=e,this.J=n,this.url=i,this.file=o,this.coords=r,this.R=a,this.X=s,this.F=0,this.A=0,this.V=0,this.q={},this.H=new Set,this.Y=null;const l=Array.isArray(g)?g:[];this.U=new Set(l.filter(t=>"transparent"!==(t?.name||"").toLowerCase()&&Array.isArray(t?.rgb)).map(t=>`${t.rgb[0]},${t.rgb[1]},${t.rgb[2]}`));const m="222,250,206";this.U.add(m);const c="other";this.U.add(c),this.K=new Map(l.filter(t=>Array.isArray(t?.rgb)).map(t=>[`${t.rgb[0]},${t.rgb[1]},${t.rgb[2]}`,{id:t.id,premium:!!t.premium,name:t.name}]));try{const t=l.find(t=>"transparent"===(t?.name||"").toLowerCase());t&&Array.isArray(t.rgb)&&this.K.set(m,{id:t.id,premium:!!t.premium,name:t.name})}catch(t){}try{this.K.set(c,{id:"other",premium:!1,name:"Other"})}catch(t){}console.log("模板的允许颜色:",this.U)}async Z(){console.log("模板坐标:",this.coords);const t=await createImageBitmap(this.file),e=t.width,n=t.height,i=e*n;console.log(`模板像素分析 - 尺寸:${e}×${n} = ${i.toLocaleString()} 像素`),this.F=i;try{const i=new OffscreenCanvas(e,n).getContext("2d",{tt:!0});i.imageSmoothingEnabled=!1,i.clearRect(0,0,e,n),i.drawImage(t,0,0);const o=i.getImageData(0,0,e,n).data;let r=0,a=0;const s=new Map;for(let t=0;t<n;t++)for(let n=0;n<e;n++){const i=4*(t*e+n),l=o[i],m=o[i+1],c=o[i+2];if(0===o[i+3])continue;222===l&&250===m&&206===c&&a++;const u=this.U.has(`${l},${m},${c}`)?`${l},${m},${c}`:"other";r++,s.set(u,(s.get(u)||0)+1)}this.A=r,this.V=a;const l={};for(const[t,e]of s.entries())l[t]={count:e,enabled:!0};this.q=l}catch(t){this.A=Math.max(0,this.F),this.V=0,console.warn("无法计算所需/涂改数量,回退为总像素。",t)}const o={},r={},a=new OffscreenCanvas(this.X,this.X),s=a.getContext("2d",{tt:!0});for(let i=this.coords[3];i<n+this.coords[3];){const m=Math.min(this.X-i%this.X,n-(i-this.coords[3]));console.log(`Math.min(${this.X} - (${i} % ${this.X}), ${n} - (${i-this.coords[3]}))`);for(let n=this.coords[2];n<e+this.coords[2];){console.log(`像素 X: ${n}\n像素 Y: ${i}`);const c=Math.min(this.X-n%this.X,e-(n-this.coords[2]));console.log(`Math.min(${this.X} - (${n} % ${this.X}), ${e} - (${n-this.coords[2]}))`),console.log(`绘制尺寸 X: ${c}\n绘制尺寸 Y: ${m}`);const u=3*c,d=3*m;a.width=u,a.height=d,console.log(`绘制 X: ${c}\n绘制 Y: ${m}\n画布宽度: ${u}\n画布高度: ${d}`),s.imageSmoothingEnabled=!1,console.log(`获取 X ${n}-${n+c}\n获取 Y ${i}-${i+m}`),s.clearRect(0,0,u,d),s.drawImage(t,n-this.coords[2],i-this.coords[3],c,m,0,0,3*c,3*m);const b=s.getImageData(0,0,u,d);for(let t=0;t<d;t++)for(let e=0;e<u;e++){const n=4*(t*u+e);if(222===b.data[n]&&250===b.data[n+1]&&206===b.data[n+2])(e+t)%2==0?(b.data[n]=0,b.data[n+1]=0,b.data[n+2]=0):(b.data[n]=255,b.data[n+1]=255,b.data[n+2]=255),b.data[n+3]=32;else if(e%3!=1||t%3!=1)b.data[n+3]=0;else{const t=b.data[n],e=b.data[n+1],i=b.data[n+2];this.U.has(`${t},${e},${i}`)}}console.log(`为 ${n}, ${i} 碎片化像素`,b),s.putImageData(b,0,0);const h=`${(this.coords[0]+Math.floor(n/1e3)).toString().padStart(4,"0")},${(this.coords[1]+Math.floor(i/1e3)).toString().padStart(4,"0")},${(n%1e3).toString().padStart(3,"0")},${(i%1e3).toString().padStart(3,"0")}`;o[h]=await createImageBitmap(a),this.H.add(h.split(",").slice(0,2).join(","));const p=await a.convertToBlob(),g=await p.arrayBuffer(),f=Array.from(new Uint8Array(g));r[h]=l(f),console.log(o),n+=c}i+=m}return console.log("模板区块: ",o),console.log("模板区块缓冲区: ",r),{et:o,nt:r}}};c=new WeakSet,u=async function(){GM.setValue("bmTemplates",JSON.stringify(this.it))},d=async function(t){console.log("正在解析 BlueMarble...");const e=t.templates;if(console.log(`BlueMarble 长度: ${Object.keys(e).length}`),Object.keys(e).length>0){for(const t in e){const n=t,i=e[t];if(console.log(n),e.hasOwnProperty(t)){const t=n.split(" "),o=Number(t?.[0]),r=t?.[1]||"0",a=i.name||`Template ${o||""}`,s=i.tiles,l={};let c=0;const u=new Map;for(const t in s)if(console.log(t),s.hasOwnProperty(t)){const e=m(s[t]),n=new Blob([e],{type:"image/png"}),i=await createImageBitmap(n);l[t]=i;try{const t=i.width,e=i.height,n=new OffscreenCanvas(t,e).getContext("2d",{tt:!0});n.imageSmoothingEnabled=!1,n.clearRect(0,0,t,e),n.drawImage(i,0,0);const o=n.getImageData(0,0,t,e).data;for(let n=0;n<e;n++)for(let e=0;e<t;e++){if(e%this.ot!==1||n%this.ot!==1)continue;const i=4*(n*t+e),r=o[i],a=o[i+1],s=o[i+2];if(o[i+3]<64)continue;if(222===r&&250===a&&206===s)continue;c++;const l=activeTemplate.U.has(`${r},${a},${s}`)?`${r},${a},${s}`:"other";u.set(l,(u.get(l)||0)+1)}}catch(t){console.warn("无法统计导入tile所需的像素",t)}}const d=new f({displayName:a,W:o||this.rt?.length||0,J:r||""});d.R=l,d.A=c;const b={};for(const[t,e]of u.entries())b[t]={count:e,enabled:!0};d.q=b;try{Object.keys(l).forEach(t=>{d.H?.add(t.split(",").slice(0,2).join(","))})}catch(t){}try{const t=e?.[n]?.palette;if(t)for(const[e,n]of Object.entries(t))d.q[e]?d.q[e].enabled=!!n?.enabled:d.q[e]={count:n?.count||0,enabled:!!n?.enabled}}catch(t){}d.Y=n,this.rt.push(d),console.log(this.rt),console.log("^^^ 这个 ^^^")}}try{const t=document.querySelector("#bm-contain-colorfilter");t&&(t.style.display=""),window.postMessage({source:"blue-marble",st:"bm-rebuild-color-list"},"*")}catch(t){}}},b=new WeakSet,h=async function(t=navigator.userAgent){return(t=t||"").includes("OPR/")||t.includes("Opera")?"Opera":t.includes("Edg/")?"Edge":t.includes("Vivaldi")?"Vivaldi":t.includes("YaBrowser")?"Yandex":t.includes("Kiwi")?"Kiwi":t.includes("Brave")?"Brave":t.includes("Firefox/")?"Firefox":t.includes("Chrome/")?"Chrome":t.includes("Safari/")?"Safari":navigator.brave&&"function"==typeof navigator.brave.isBrave&&await navigator.brave.isBrave()?"Brave":"Unknown"},p=function(t=navigator.userAgent){return/Windows NT 11/i.test(t=t||"")?"Windows 11":/Windows NT 10/i.test(t)?"Windows 10":/Windows NT 6\.3/i.test(t)?"Windows 8.1":/Windows NT 6\.2/i.test(t)?"Windows 8":/Windows NT 6\.1/i.test(t)?"Windows 7":/Windows NT 6\.0/i.test(t)?"Windows Vista":/Windows NT 5\.1|Windows XP/i.test(t)?"Windows XP":/Mac OS X 10[_\.]15/i.test(t)?"macOS Catalina":/Mac OS X 10[_\.]14/i.test(t)?"macOS Mojave":/Mac OS X 10[_\.]13/i.test(t)?"macOS High Sierra":/Mac OS X 10[_\.]12/i.test(t)?"macOS Sierra":/Mac OS X 10[_\.]11/i.test(t)?"OS X El Capitan":/Mac OS X 10[_\.]10/i.test(t)?"OS X Yosemite":/Mac OS X 10[_\.]/i.test(t)?"macOS":/Android/i.test(t)?"Android":/iPhone|iPad|iPod/i.test(t)?"iOS":/Linux/i.test(t)?"Linux":"Unknown"};var y=GM_info.script.name.toString(),w=GM_info.script.version.toString();!function(t){const e=document.createElement("script");e.setAttribute("bm-name",y),e.setAttribute("bm-cStyle","color: cornflowerblue;"),e.textContent=`(${t})();`,document.documentElement?.appendChild(e),e.remove()}(()=>{const t=document.currentScript,e=t?.getAttribute("bm-name")||"Blue Marble",n=t?.getAttribute("bm-cStyle")||"",i=new Map;window.addEventListener("message",t=>{const{source:o,endpoint:r,blobID:a,blobData:s,blink:l}=t.data,m=Date.now()-l;if(console.groupCollapsed(`%c${e}%c: ${i.size} Recieved IMAGE message about blob "${a}"`,n,""),console.log(`Blob fetch took %c${String(Math.floor(m/6e4)).padStart(2,"0")}:${String(Math.floor(m/1e3)%60).padStart(2,"0")}.${String(m%1e3).padStart(3,"0")}%c MM:SS.mmm`,n,""),console.log(i),console.groupEnd(),"blue-marble"==o&&a&&s&&!r){const t=i.get(a);"function"==typeof t?t(s):function(...t){(0,console.warn)(...t)}(`%c${e}%c: 尝试从队列中检索 blob (%s),但 blobID 不是一个函数!跳过...`,n,"",a),i.delete(a)}});const o=window.fetch;window.fetch=async function(...t){const r=await o.apply(this,t),a=r.clone(),s=(t[0]instanceof Request?t[0]?.url:t[0])||"ignore",l=a.headers.get("content-type")||"";if(l.includes("application/json"))console.log(`%c${e}%c: 正在发送有关端点 "${s}" 的 JSON 消息`,n,""),a.json().then(t=>{window.postMessage({source:"blue-marble",endpoint:s,jsonData:t},"*")}).catch(t=>{console.error(`%c${e}%c: JSON 解析失败: `,n,"",t)});else if(l.includes("image/")&&!s.includes("openfreemap")&&!s.includes("maps")){const t=Date.now(),o=await a.blob();return console.log(`%c${e}%c: ${i.size} 正在发送有关端点 "${s}" 的 IMAGE 消息`,n,""),new Promise(r=>{const l=crypto.randomUUID();i.set(l,t=>{r(new Response(t,{headers:a.headers,status:a.status,statusText:a.statusText})),console.log(`%c${e}%c: ${i.size} 已处理 blob "${l}"`,n,"")}),window.postMessage({source:"blue-marble",endpoint:s,blobID:l,blobData:o,blink:t})}).catch(o=>{const r=Date.now();console.error(`%c${e}%c: Promise blob 失败!`,n,""),console.groupCollapsed(`%c${e}%c: 失败的 blob Promise 详细信息:`,n,""),console.log(`端点: ${s}\n当前有 ${i.size} 个 blob 正在处理...\n闪烁: ${t.toLocaleString()}\n距离上次闪烁的时间: ${String(Math.floor(r/6e4)).padStart(2,"0")}:${String(Math.floor(r/1e3)%60).padStart(2,"0")}.${String(r%1e3).padStart(3,"0")} 分:秒.毫秒`),console.error("异常堆栈:",o),console.groupEnd()})}return r}});var v=GM_getResourceText("CSS-BM-File");GM_addStyle(v);var x=document.createElement("link");x.href="https://fonts.googleapis.com/css2?family=Roboto+Mono:ital,wght@0,100..700;1,100..700&display=swap",x.rel="preload",x.as="style",x.onload=function(){this.onload=null,this.rel="stylesheet"},document.head?.appendChild(x),new class{constructor(){this.lt=null,this.ct=null,this.ut="#bm-display-coords"}dt(t){return this.ct=t,this.lt=new MutationObserver(t=>{for(const e of t)for(const t of e.addedNodes)t instanceof HTMLElement&&t.matches?.(this.ut)}),this}bt(){return this.lt}observe(t,e=!1,n=!1){t.observe(this.ct,{childList:e,subtree:n})}};var $=new r(y,w),S=(new r(y,w),new class{constructor(t,e,n){i(this,c),this.name=t,this.version=e,this.o=n,this.ht="1.0.0",this.gt=null,this.ft="!#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwxyz{|}~",this.X=1e3,this.ot=3,this.yt=null,this.wt=null,this.vt="bm-canvas",this.xt="div#map canvas.maplibregl-canvas",this.$t=null,this.St="",this.rt=[],this.it=null,this.Mt=!0,this.Ot=new Map}kt(){if(document.body.contains(this.yt))return this.yt;document.getElementById(this.vt)?.remove();const t=document.querySelector(this.xt),e=document.createElement("canvas");return e.id=this.vt,e.className="maplibregl-canvas",e.style.position="absolute",e.style.top="0",e.style.left="0",e.style.height=t?.clientHeight*(window.devicePixelRatio||1)+"px",e.style.width=t?.clientWidth*(window.devicePixelRatio||1)+"px",e.height=t?.clientHeight*(window.devicePixelRatio||1),e.width=t?.clientWidth*(window.devicePixelRatio||1),e.style.zIndex="8999",e.style.pointerEvents="none",t?.parentElement?.appendChild(e),this.yt=e,window.addEventListener("move",this.Nt),window.addEventListener("zoom",this.Tt),window.addEventListener("resize",this.Ct),this.yt}async Bt(){return{whoami:this.name.replace(" ",""),scriptVersion:this.version,schemaVersion:this.ht,templates:{}}}async Dt(t,e,n){this.it||(this.it=await this.Bt(),console.log("正在创建 JSON...")),this.o.P(`正在 ${n.join(", ")} 处创建模板...`);const i=new f({displayName:e,W:0,J:s(this.gt||0,this.ft),file:t,coords:n}),{et:r,nt:a}=await i.Z(this.X);i.R=r;const l=`${i.W} ${i.J}`;i.Y=l,this.it.templates[l]={name:i.displayName,coords:n.join(", "),enabled:!0,tiles:a,palette:i.q},this.rt=[],this.rt.push(i);const m=(new Intl.NumberFormat).format(i.F);this.o.P(`模板已在 ${n.join(", ")}! 处创建! 总像素数: ${m}`);try{const t=document.querySelector("#bm-contain-colorfilter");t&&(t.style.display=""),window.postMessage({source:"blue-marble",st:"bm-rebuild-color-list"},"*")}catch(t){}console.log(Object.keys(this.it.templates).length),console.log(this.it),console.log(this.rt),console.log(JSON.stringify(this.it)),await o(this,c,u).call(this)}It(){}async Lt(){this.it||(this.it=await this.Bt(),console.log("正在创建 JSON..."))}async Gt(t,e){if(!this.Mt)return t;const n=this.X*this.ot;e=e[0].toString().padStart(4,"0")+","+e[1].toString().padStart(4,"0"),console.log(`正在tile中搜索模板:"${e}"`);const i=this.rt;if(console.log(i),i.sort((t,e)=>t.W-e.W),console.log(i),!i.some(t=>!!t?.R&&(t.H&&t.H.size>0?t.H.has(e):Object.keys(t.R).some(t=>t.startsWith(e)))))return t;const o=i.map(t=>{const n=Object.keys(t.R).filter(t=>t.startsWith(e));if(0===n.length)return null;const i=n.map(e=>{const n=e.split(",");return{jt:t.R[e],_t:[n[0],n[1]],Pt:[n[2],n[3]]}});return i?.[0]}).filter(Boolean);console.log(o);const r=o?.length||0;console.log(`templateCount = ${r}`);let a=0,s=0,l=0;const m=await createImageBitmap(t),c=new OffscreenCanvas(n,n),u=c.getContext("2d");u.imageSmoothingEnabled=!1,u.beginPath(),u.rect(0,0,n,n),u.clip(),u.clearRect(0,0,n,n),u.drawImage(m,0,0,n,n);let d=null;try{d=u.getImageData(0,0,n,n).data}catch(t){}for(const t of o){if(console.log("模板:"),console.log(t),d)try{const e=t.jt.width,i=t.jt.height,o=new OffscreenCanvas(e,i).getContext("2d",{tt:!0});o.imageSmoothingEnabled=!1,o.clearRect(0,0,e,i),o.drawImage(t.jt,0,0);const r=o.getImageData(0,0,e,i).data,m=Number(t.Pt[0])*this.ot,c=Number(t.Pt[1])*this.ot;for(let t=0;t<i;t++)for(let i=0;i<e;i++){if(i%this.ot!==1||t%this.ot!==1)continue;const o=i+m,u=t+c;if(o<0||u<0||o>=n||u>=n)continue;const b=4*(t*e+i),h=r[b],p=r[b+1],g=r[b+2];if(r[b+3]<64){try{const t=this.rt?.[0],e=4*(u*n+o),i=d[e],r=d[e+1],a=d[e+2],l=d[e+3],m=t.U.has(`${i},${r},${a}`)?`${i},${r},${a}`:"other",c=!!t?.U&&t.U.has(m);l>=64&&c&&s++}catch(t){}continue}l++;const f=4*(u*n+o),y=d[f],w=d[f+1],v=d[f+2];d[f+3]<64||(y===h&&w===p&&v===g?a++:s++)}}catch(t){console.warn("未能统计各 Tile 的已涂画与错误数据:",t)}try{const e=this.rt?.[0],n=e?.q||{};if(Object.values(n).some(t=>!1===t?.enabled)){console.log("正在应用颜色过滤器...");const i=t.jt.width,o=t.jt.height,r=new OffscreenCanvas(i,o),a=r.getContext("2d",{tt:!0});a.imageSmoothingEnabled=!1,a.clearRect(0,0,i,o),a.drawImage(t.jt,0,0);const s=a.getImageData(0,0,i,o),l=s.data;for(let t=0;t<o;t++)for(let o=0;o<i;o++){if(o%this.ot!==1||t%this.ot!==1)continue;const r=4*(t*i+o),a=l[r],s=l[r+1],m=l[r+2];if(l[r+3]<1)continue;let c=e.U.has(`${a},${s},${m}`)?`${a},${s},${m}`:"other";(!e?.U||e.U.has(c))&&!1!==n?.[c]?.enabled||(l[r+3]=0)}a.putImageData(s,0,0),u.drawImage(r,Number(t.Pt[0])*this.ot,Number(t.Pt[1])*this.ot)}else u.drawImage(t.jt,Number(t.Pt[0])*this.ot,Number(t.Pt[1])*this.ot)}catch(e){console.warn("应用颜色过滤器失败:",e),u.drawImage(t.jt,Number(t.Pt[0])*this.ot,Number(t.Pt[1])*this.ot)}}if(r>0){const t=e;this.Ot.set(t,{Wt:a,required:l,Jt:s});let n=0,i=0,o=0;for(const t of this.Ot.values())n+=t.Wt||0,i+=t.required||0,o+=t.Jt||0;const m=this.rt.reduce((t,e)=>t+(e.A||e.F||0),0),c=m>0?m:i,u=(new Intl.NumberFormat).format(n),d=(new Intl.NumberFormat).format(c),b=(new Intl.NumberFormat).format(c-n);this.o.P(`正在显示 ${r} template${1==r?"":"s"} 个模板。\n已绘制 ${u} / ${d} • 错误 ${b}`)}else this.o.P(`正在显示 ${r} 个模板。`);return await c.convertToBlob({type:"image/png"})}Rt(t){console.log("正在导入 JSON..."),console.log(t),"BlueMarble"==t?.whoami&&o(this,c,d).call(this,t)}Xt(t){this.Mt=t}}(y,w,$)),M=new class{constructor(t){i(this,b),this.Ft=t,this.At=!1,this.Vt=[],this.Et=[]}qt(t){window.addEventListener("message",async e=>{const n=e.data,i=n.jsonData;if(!n||"blue-marble"!==n.source)return;if(!n.endpoint)return;const o=n.endpoint?.split("?")[0].split("/").filter(t=>t&&isNaN(Number(t))).filter(t=>t&&!t.includes(".")).pop();switch(console.log('%cBlue Marble%c: Recieved message about "%s"',"color: cornflowerblue;","",o),o){case"me":if(i.status&&"2"!=i.status?.toString()[0])return void t._("您未登录!\n无法获取用户数据。");const e=Math.ceil(Math.pow(Math.floor(i.level)*Math.pow(30,.65),1/.65)-i.pixelsPainted);console.log(i.id),(i.id||0===i.id)&&console.log(s(i.id,"!#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwxyz{|}~")),this.Ft.gt=i.id,t.D("bm-user-name",`用户名: <b>${function(t){const e=document.createElement("div");return e.textContent=t,e.innerHTML}(i.name)}</b>`),t.D("bm-user-droplets",`Droplets数量: <b>${(new Intl.NumberFormat).format(i.droplets)}</b>`),t.D("bm-user-nextlevel",`距下一等级还有 <b>${(new Intl.NumberFormat).format(e)}</b> 像素${1==e?"":"s"}`);break;case"pixel":const o=n.endpoint.split("?")[0].split("/").filter(t=>t&&!isNaN(Number(t))),l=new URLSearchParams(n.endpoint.split("?")[1]),m=[l.get("x"),l.get("y")];if(this.Vt.length&&(!o.length||!m.length))return void t._("坐标格式不正确!\n您是否先尝试点击了画布?");this.Vt=[...o,...m];const c=(r=o,a=m,[parseInt(r[0])%4*1e3+parseInt(a[0]),parseInt(r[1])%4*1e3+parseInt(a[1])]),u=document.querySelectorAll("span");for(const t of u)if(t.textContent.trim().includes(`${c[0]}, ${c[1]}`)){let e=document.querySelector("#bm-display-coords");const n=`(块 X: ${o[0]}, 块 Y: ${o[1]}, 像素 X: ${m[0]}, 像素 Y: ${m[1]})`;e?e.textContent=n:(e=document.createElement("span"),e.id="bm-display-coords",e.textContent=n,e.style="margin-left: calc(var(--spacing)*3); font-size: small;",t.parentNode.parentNode.parentNode.insertAdjacentElement("afterend",e))}break;case"tiles":let d=n.endpoint.split("/");d=[parseInt(d[d.length-2]),parseInt(d[d.length-1].replace(".png",""))];const b=n.blobID,h=n.blobData,p=await this.Ft.Gt(h,d);window.postMessage({source:"blue-marble",blobID:b,blobData:p,blink:n.blink});break;case"robots":this.At="false"==i.userscript?.toString().toLowerCase();break}var r,a})}async zt(t){console.log("Sending heartbeat to telemetry server...");let e=GM_getValue("bmUserSettings","{}");if(e=JSON.parse(e),!e||!e.telemetry||!e.uuid)return void console.log("Telemetry is disabled, not sending heartbeat.");const n=navigator.userAgent;let i=await o(this,b,h).call(this,n),r=o(this,b,p).call(this,n);GM_xmlhttpRequest({method:"POST",url:"https://telemetry.thebluecorner.net/heartbeat",headers:{"Content-Type":"application/json"},data:JSON.stringify({uuid:e.uuid,version:t,browser:i,os:r}),onload:t=>{200!==t.status&&a("Failed to send heartbeat:",t.statusText)},onerror:t=>{a("Error sending heartbeat:",t)}})}}(S);$.u(M);var O=JSON.parse(GM_getValue("bmTemplates","{}"));console.log(O),S.Rt(O);var k=JSON.parse(GM_getValue("bmUserSettings","{}"));if(console.log(k),console.log(Object.keys(k).length),0==Object.keys(k).length){const t=crypto.randomUUID();console.log(t),GM.setValue("bmUserSettings",JSON.stringify({uuid:t}))}if(setInterval(()=>M.zt(w),18e5),console.log(`Telemetry is ${!(null==k?.telemetry)}`),null==k?.telemetry||k?.telemetry>1){const t=new r(y,w);t.u(M),t.v({id:"bm-overlay-telemetry",style:"top: 0px; left: 0px; width: 100vw; max-width: 100vw; height: 100vh; max-height: 100vh; z-index: 9999;"}).v({id:"bm-contain-all-telemetry",style:"display: flex; flex-direction: column; align-items: center;"}).v({id:"bm-contain-header-telemetry",style:"margin-top: 10%;"}).O(1,{textContent:`${y} Telemetry`}).h().h().v({id:"bm-contain-telemetry",style:"max-width: 50%; overflow-y: auto; max-height: 80vh;"}).k().h().N().h().v({style:"width: fit-content; margin: auto; text-align: center;"}).C({id:"bm-button-telemetry-more",textContent:"更多信息"},(t,e)=>{e.onclick=()=>{window.open("https://github.com/SwingTheVine/Wplace-TelemetryServer#telemetry-data","_blank","noopener noreferrer")}}).h().h().N().h().v({style:"width: fit-content; margin: auto; text-align: center;"}).C({id:"bm-button-telemetry-enable",textContent:"启用遥测",style:"margin-right: 2ch;"},(t,e)=>{e.onclick=()=>{const t=JSON.parse(GM_getValue("bmUserSettings","{}"));t.telemetry=1,GM.setValue("bmUserSettings",JSON.stringify(t));const e=document.getElementById("bm-overlay-telemetry");e&&(e.style.display="none")}}).h().C({id:"bm-button-telemetry-disable",textContent:"禁用遥测"},(t,e)=>{e.onclick=()=>{const t=JSON.parse(GM_getValue("bmUserSettings","{}"));t.telemetry=0,GM.setValue("bmUserSettings",JSON.stringify(t));const e=document.getElementById("bm-overlay-telemetry");e&&(e.style.display="none")}}).h().h().N().h().$({textContent:"我们收集匿名遥测数据,例如您的浏览器、操作系统和脚本版本,以改善每个人的体验。数据绝不会被个人分享,也绝不会被出售。您可以通过按“禁用”按钮来关闭此功能,但保持开启有助于我们更快地改进功能和可靠性。感谢您对 Blue Marble 的支持!"}).h().$({textContent:"您可以通过按下面的“禁用”按钮来禁用遥测。"}).h().h().h().p(document.body)}!function(){let t=!1,e={};try{e=JSON.parse(GM_getValue("bmCoords","{}"))||{}}catch(t){e={}}const n=()=>{try{const t=Number(document.querySelector("#bm-input-tx")?.value||""),e=Number(document.querySelector("#bm-input-ty")?.value||""),n={Ht:t,Yt:e,px:Number(document.querySelector("#bm-input-px")?.value||""),Ut:Number(document.querySelector("#bm-input-py")?.value||"")};GM.setValue("bmCoords",JSON.stringify(n))}catch(t){}};$.v({id:"bm-overlay",style:"top: 10px; right: 75px;"}).v({id:"bm-contain-header"}).v({id:"bm-bar-drag"}).h().M({alt:"Blue Marble 图标 - 点击最小化/最大化",src:"https://raw.githubusercontent.com/SwingTheVine/Wplace-BlueMarble/main/dist/assets/Favicon.png",style:"cursor: pointer;"},(e,n)=>{n.addEventListener("click",()=>{t=!t;const i=document.querySelector("#bm-overlay"),o=document.querySelector("#bm-contain-header"),r=document.querySelector("#bm-bar-drag"),a=document.querySelector("#bm-contain-coords"),s=document.querySelector("#bm-button-coords"),l=document.querySelector("#bm-button-create"),m=document.querySelector("#bm-button-enable"),c=document.querySelector("#bm-button-disable"),u=document.querySelectorAll("#bm-contain-coords input");t||(i.style.width="auto",i.style.maxWidth="300px",i.style.minWidth="200px",i.style.padding="10px"),["#bm-overlay h1","#bm-contain-userinfo","#bm-overlay hr","#bm-contain-automation > *:not(#bm-contain-coords)","#bm-input-file-template","#bm-contain-buttons-action",`#${e.i}`,"#bm-contain-colorfilter"].forEach(e=>{document.querySelectorAll(e).forEach(e=>{e.style.display=t?"none":""})}),t?(a&&(a.style.display="none"),s&&(s.style.display="none"),l&&(l.style.display="none"),m&&(m.style.display="none"),c&&(c.style.display="none"),u.forEach(t=>{t.style.display="none"}),i.style.width="60px",i.style.height="76px",i.style.maxWidth="60px",i.style.minWidth="60px",i.style.padding="8px",n.style.marginLeft="3px",o.style.textAlign="center",o.style.margin="0",o.style.marginBottom="0",r&&(r.style.display="",r.style.marginBottom="0.25em")):(a&&(a.style.display="",a.style.flexDirection="",a.style.justifyContent="",a.style.alignItems="",a.style.gap="",a.style.textAlign="",a.style.margin=""),s&&(s.style.display=""),l&&(l.style.display="",l.style.marginTop=""),m&&(m.style.display="",m.style.marginTop=""),c&&(c.style.display="",c.style.marginTop=""),u.forEach(t=>{t.style.display=""}),n.style.marginLeft="",i.style.padding="10px",o.style.textAlign="",o.style.margin="",o.style.marginBottom="",r&&(r.style.marginBottom="0.5em"),i.style.width="",i.style.height=""),n.alt=t?"Blue Marble 图标 - 已最小化(点击最大化)":"Blue Marble 图标 - 已最大化(点击最小化)"})}).h().O(1,{textContent:y}).h().h().k().h().v({id:"bm-contain-userinfo"}).$({id:"bm-user-name",textContent:"用户名:"}).h().$({id:"bm-user-droplets",textContent:"Droplets数量:"}).h().$({id:"bm-user-nextlevel",textContent:"距离下一级..."}).h().h().k().h().v({id:"bm-contain-automation"}).v({id:"bm-contain-coords"}).C({id:"bm-button-coords",className:"bm-help",style:"margin-top: 0;",innerHTML:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 4 6"><circle cx="2" cy="2" r="2"></circle><path d="M2 6 L3.7 3 L0.3 3 Z"></path><circle cx="2" cy="2" r="0.7" fill="white"></circle></svg></svg>'},(t,e)=>{e.onclick=()=>{const e=t.t?.Vt;e?.[0]?(t.D("bm-input-tx",e?.[0]||""),t.D("bm-input-ty",e?.[1]||""),t.D("bm-input-px",e?.[2]||""),t.D("bm-input-py",e?.[3]||""),n()):t._("坐标格式不正确!你是不是还没有点击画布?")}}).h().I({type:"number",id:"bm-input-tx",placeholder:"Tl X",min:0,max:2047,step:1,required:!0,value:e.Ht??""},(t,e)=>{e.addEventListener("paste",t=>{let e=(t.clipboardData||window.clipboardData).getData("text").split(" ").filter(t=>t).map(Number).filter(t=>!isNaN(t));if(4!==e.length)return;let n=(i=document,coords=[],coords.push(i.querySelector("#bm-input-tx")),coords.push(i.querySelector("#bm-input-ty")),coords.push(i.querySelector("#bm-input-px")),coords.push(i.querySelector("#bm-input-py")),coords);var i;for(let t=0;t<n.length;t++)n[t].value=e[t];t.preventDefault()});const i=()=>n();e.addEventListener("input",i),e.addEventListener("change",i)}).h().I({type:"number",id:"bm-input-ty",placeholder:"Tl Y",min:0,max:2047,step:1,required:!0,value:e.Yt??""},(t,e)=>{const i=()=>n();e.addEventListener("input",i),e.addEventListener("change",i)}).h().I({type:"number",id:"bm-input-px",placeholder:"Px X",min:0,max:2047,step:1,required:!0,value:e.px??""},(t,e)=>{const i=()=>n();e.addEventListener("input",i),e.addEventListener("change",i)}).h().I({type:"number",id:"bm-input-py",placeholder:"Px Y",min:0,max:2047,step:1,required:!0,value:e.Ut??""},(t,e)=>{const i=()=>n();e.addEventListener("input",i),e.addEventListener("change",i)}).h().h().v({id:"bm-contain-colorfilter",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-button-colors-enable-all",textContent:"全部启用"},(t,e)=>{e.onclick=()=>{const e=S.rt[0];e?.q&&(Object.values(e.q).forEach(t=>t.enabled=!0),buildColorFilterList(),t.P("已启用所有颜色"))}}).h().C({id:"bm-button-colors-disable-all",textContent:"全部禁用"},(t,e)=>{e.onclick=()=>{const e=S.rt[0];e?.q&&(Object.values(e.q).forEach(t=>t.enabled=!1),buildColorFilterList(),t.P("已禁用所有颜色"))}}).h().h().v({id:"bm-colorfilter-list"}).h().h().L({id:"bm-input-file-template",textContent:"上传模板",accept:"image/png, image/jpeg, image/webp, image/bmp, image/gif"}).h().v({id:"bm-contain-buttons-template"}).C({id:"bm-button-enable",textContent:"启用"},(t,e)=>{e.onclick=()=>{t.t?.Ft?.Xt(!0),t.P("模板已启用!")}}).h().C({id:"bm-button-create",textContent:"创建"},(t,e)=>{e.onclick=()=>{const e=document.querySelector("#bm-input-file-template"),n=document.querySelector("#bm-input-tx");if(!n.checkValidity())return n.reportValidity(),void t._("坐标格式不正确!你是不是还没有点击画布?");const i=document.querySelector("#bm-input-ty");if(!i.checkValidity())return i.reportValidity(),void t._("坐标格式不正确!你是不是还没有点击画布?");const o=document.querySelector("#bm-input-px");if(!o.checkValidity())return o.reportValidity(),void t._("坐标格式不正确!你是不是还没有点击画布?");const r=document.querySelector("#bm-input-py");if(!r.checkValidity())return r.reportValidity(),void t._("坐标格式不正确!你是不是还没有点击画布?");e?.files[0]?(S.Dt(e.files[0],e.files[0]?.name.replace(/\.[^/.]+$/,""),[Number(n.value),Number(i.value),Number(o.value),Number(r.value)]),t.P("已绘制到画布!")):t._("未选择文件!")}}).h().C({id:"bm-button-disable",textContent:"禁用"},(t,e)=>{e.onclick=()=>{t.t?.Ft?.Xt(!1),t.P("模板已禁用!")}}).h().h().G({id:$.i,placeholder:`状态: 休眠中...\n版本: ${w}`,readOnly:!0}).h().v({id:"bm-contain-buttons-action"}).v().C({id:"bm-button-convert",className:"bm-help",innerHTML:"🎨",title:"模板颜色转换器"},(t,e)=>{e.addEventListener("click",()=>{window.open("https://pepoafonso.github.io/color_converter_wplace/","_blank","noopener noreferrer")})}).h().C({id:"bm-button-website",className:"bm-help",innerHTML:"🌐",title:"Blue Marble 官方网站"},(t,e)=>{e.addEventListener("click",()=>{window.open("https://bluemarble.camilledaguin.fr/","_blank","noopener noreferrer")})}).h().h().S({textContent:"SwingTheVine 制作 | Muyue 汉化",style:"margin-top: auto;"}).h().h().h().p(document.body),window.buildColorFilterList=function(){const t=document.querySelector("#bm-colorfilter-list"),e=S.rt?.[0];if(!t||!e?.q)return void(t&&(t.innerHTML="<small>无模板颜色可显示。</small>"));t.innerHTML="";const n=Object.entries(e.q).sort((t,e)=>e[1].count-t[1].count);for(const[e,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 r=document.createElement("span");r.style.fontSize="12px";let a=`${i.count.toLocaleString()}`;if("other"===e)o.style.background="#888",a=`Other • ${a}`;else if("#deface"===e)o.style.background="#deface",a=`Transparent • ${a}`;else{const[t,n,i]=e.split(",").map(Number);o.style.background=`rgb(${t},${n},${i})`;try{const o=S.rt?.[0]?.K?.get(e);if(o&&"number"==typeof o.id){const e=o?.name||`rgb(${t},${n},${i})`,r=o.premium?"★ ":"";a=`#${o.id} ${r}${e} • ${a}`}}catch(t){}}r.textContent=a;const s=document.createElement("input");s.type="checkbox",s.checked=!!i.enabled,s.addEventListener("change",()=>{i.enabled=s.checked,$.P(`${s.checked?"已启用":"已禁用"} ${e}`);try{const t=S.rt?.[0],e=t?.Y;t&&e&&S.it?.templates?.[e]&&(S.it.templates[e].palette=t.q,GM.setValue("bmTemplates",JSON.stringify(S.it)))}catch(t){}}),n.appendChild(s),n.appendChild(o),n.appendChild(r),t.appendChild(n)}},window.addEventListener("message",t=>{if("bm-rebuild-color-list"===t?.data?.st)try{buildColorFilterList()}catch(t){}}),setTimeout(()=>{try{if(S.rt?.length>0){const t=document.querySelector("#bm-contain-colorfilter");t&&(t.style.display=""),buildColorFilterList()}}catch(t){}},0)}(),$.j("#bm-overlay","#bm-bar-drag"),M.qt($),new MutationObserver((t,e)=>{const n=document.querySelector("#color-1");if(!n)return;let i=document.querySelector("#bm-button-move");if(!i){i=document.createElement("button"),i.id="bm-button-move",i.textContent="移动 ↑",i.className="btn btn-soft",i.onclick=function(){const t=this.parentNode.parentNode.parentNode.parentNode,e="移动 ↑"==this.textContent;t.parentNode.className=t.parentNode.className.replace(e?"bottom":"top",e?"top":"bottom"),t.style.borderTopLeftRadius=e?"0px":"var(--radius-box)",t.style.borderTopRightRadius=e?"0px":"var(--radius-box)",t.style.borderBottomLeftRadius=e?"var(--radius-box)":"0px",t.style.borderBottomRightRadius=e?"var(--radius-box)":"0px",this.textContent=e?"移动 ↓":"移动 ↑"};const t=n.parentNode.parentNode.parentNode.parentNode.querySelector("h2");t.parentNode?.appendChild(i)}}).observe(document.body,{childList:!0,subtree:!0}),function(...t){(0,console.log)(...t)}(`%c${y}%c (${w}) 用户脚本已加载!`,"color: cornflowerblue;","")})();