Greasy Fork

来自缓存

Greasy Fork is available in English.

Wplace Dark Mode

8/15/2025, 4:49:32 AM

< 脚本 Wplace Dark Mode 的反馈

评价:一般 - 脚本能用,但还有一些问题

§
发布于:2025-08-31

only worked once, but stopped after refreshing

dylan-dang作者
§
发布于:2025-09-01

That's weird, have you made sure there are no issues on your end? You could try reinstalling and see if that fixes your issue.

§
发布于:2025-11-04

The issue I figure is that it doesn't work with Overlay Pro.

It initially worked when I first used the plugin, but now whenever I turn on Overlay Pro, it breaks the dark mode.

§
发布于:2025-11-04
编辑于:2025-11-04

The issue I figure is that it doesn't work with Overlay Pro.

It initially worked when I first used the plugin, but now whenever I turn on Overlay Pro, it breaks the dark mode.

Here is the solution I have for now: edit your Overlay Pro starting at the attachHook function to the detachHook function with the code below.
I also went into settings so that Wplace Dark is positioned at 1 and run time at document-start
(will update if the solution below breaks)

function attachHook() {
if (hookInstalled) return;

// Capture whatever fetch is currently active (could be Dark Mode’s)
previousFetch = page.fetch;

const hookedFetch = async (input, init) => {
const urlStr = typeof input === "string" ? input : input.url || "";

// Auto-capture overlay pixel URL
if (config.autoCapturePixelUrl && config.activeOverlayId) {
const pixelMatch = matchPixelUrl(urlStr);
if (pixelMatch) {
const ov = config.overlays.find(o => o.id === config.activeOverlayId);
if (ov) {
const changed = ov.pixelUrl !== pixelMatch.normalized;
if (changed) {
ov.pixelUrl = pixelMatch.normalized;
ov.offsetX = 0;
ov.offsetY = 0;
await saveConfig(["overlays"]);
config.autoCapturePixelUrl = false;
await saveConfig(["autoCapturePixelUrl"]);
updateUICallback?.();
const c = extractPixelCoords(ov.pixelUrl);
emit(EV_ANCHOR_SET, { overlayId: ov.id, name: ov.name, chunk1: c.chunk1, chunk2: c.chunk2, posX: c.posX, posY: c.posY });
emit(EV_AUTOCAP_CHANGED, { enabled: false });
ensureHook();
}
}
}
}

// Only modify tile fetches in overlay modes
const tileMatch = matchTileUrl(urlStr);
const validModes = ["behind", "above", "minify"];
if (!tileMatch || !validModes.includes(config.overlayMode)) {
// Call the current (possibly Dark Mode patched) fetch
return previousFetch(input, init);
}

try {
const response = await previousFetch(input, init);
if (!response.ok) return response;
const ct = (response.headers.get("Content-Type") || "").toLowerCase();
if (!ct.includes("image")) return response;

const enabledOverlays = config.overlays.filter(o => o.enabled && o.imageBase64 && o.pixelUrl);
if (enabledOverlays.length === 0) return response;

const originalBlob = await response.blob();
if (originalBlob.size > 15 * 1024 * 1024) return response;

const overlayDatas = [];
for (const ov of enabledOverlays) {
overlayDatas.push(await buildOverlayDataForChunkUnified(ov, tileMatch.chunk1, tileMatch.chunk2, config.overlayMode));
}

const finalBlob = await composeTileUnified(originalBlob, overlayDatas.filter(Boolean), config.overlayMode);
const headers = new Headers(response.headers);
headers.set("Content-Type", "image/png");
headers.delete("Content-Length");

return new Response(finalBlob, {
status: response.status,
statusText: response.statusText,
headers,
});
} catch (e) {
console.error("Overlay Pro: Error processing tile", e);
return previousFetch(input, init);
}
};

// Replace both references safely
page.fetch = hookedFetch;
window.fetch = hookedFetch;
hookInstalled = true;
}

function detachHook() {
if (!hookInstalled) return;
// Restore whatever fetch was active before Overlay Pro attached
page.fetch = previousFetch;
window.fetch = previousFetch;
hookInstalled = false;
}

发布留言

登录以发布留言。