Skip to content

Commit b55b065

Browse files
committed
🔧 Temp fix for board images extraction
Disabled websocket board images handler that stopped working Implemented DOM-based blob URL extraction as fallback Board images now extracted from SVG elements by converting blob URLs to base64 Added Live mode button auto-click for zoom feature Hidden buttons in cloned zoom center element
1 parent 1586914 commit b55b065

File tree

3 files changed

+73
-5
lines changed

3 files changed

+73
-5
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
55
## [2.2.0] - 2025-12-09
66

77
### Fixed
8+
- Temporary fix for board images extraction
9+
- Disabled websocket board images handler that stopped working after recent update
10+
- Implemented DOM-based blob URL extraction as fallback method
11+
- Board images are now extracted from SVG elements in the DOM by converting blob URLs to base64 data URLs
12+
- Ensures board images continue to work while websocket handler is being fixed
813
- Fixed Next Player On Takeout Stuck feature getting triggered twice
914
- Ensured status field is always set in websocket board data processing to prevent undefined status values
1015
- Prevents duplicate triggers when board status updates are received

entrypoints/match.content/Zoom.vue

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,17 @@ onMounted(async () => {
285285
// Get user ID on mount
286286
currentUserId.value = await getUserIdFromToken();
287287
288+
// Click Live mode button if zoom mode is set to live
289+
if (config.value?.zoom?.mode === "live") {
290+
try {
291+
const liveModeButton = await waitForElement("button[aria-label='Live mode']:not([data-active])", 5000) as HTMLButtonElement;
292+
liveModeButton.click();
293+
console.log("Autodarts Tools: Clicked Live mode button");
294+
} catch (e) {
295+
console.warn("Autodarts Tools: Could not find Live mode button", e);
296+
}
297+
}
298+
288299
await AutodartsToolsBoardImages.setValue({
289300
images: [],
290301
});
@@ -391,6 +402,13 @@ async function initCenterZoom() {
391402
// Create a duplicate of the turn element
392403
const duplicateElement = turnElement.cloneNode(true) as HTMLElement;
393404
duplicateElement.id = "autodarts-tools-zoom-center";
405+
406+
// Hide any buttons inside the cloned element
407+
const buttons = duplicateElement.querySelectorAll("button");
408+
buttons.forEach((button) => {
409+
(button as HTMLElement).style.opacity = "0";
410+
});
411+
394412
zoomCenterElement.value = duplicateElement;
395413
396414
// Set opacity of the first div to 0

utils/websocket-helpers.ts

Lines changed: 50 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -255,17 +255,62 @@ export async function processWebSocketMessage(channel: string, data: ILobbies |
255255
status: data.status || "",
256256
});
257257

258+
// Search DOM for SVG with blob: image URL after 25 0ms delay
259+
setTimeout(async () => {
260+
const svgs = document.querySelectorAll("svg");
261+
let blobUrlFound = false;
262+
for (const svg of svgs) {
263+
if (blobUrlFound) break;
264+
const images = svg.querySelectorAll("image");
265+
for (const img of images) {
266+
const href = img.getAttribute("href") || img.getAttribute("xlink:href") || img.getAttribute("src");
267+
if (href && href.startsWith("blob:")) {
268+
try {
269+
// Convert blob URL to base64 data URL
270+
const response = await fetch(href);
271+
const blob = await response.blob();
272+
const reader = new FileReader();
273+
const base64DataUrl = await new Promise<string>((resolve, reject) => {
274+
reader.onloadend = () => resolve(reader.result as string);
275+
reader.onerror = reject;
276+
reader.readAsDataURL(blob);
277+
});
278+
279+
const boardImages = await AutodartsToolsBoardImages.getValue();
280+
// Check for duplicates before adding
281+
if (!boardImages.images.includes(base64DataUrl)) {
282+
boardImages.images.push(base64DataUrl);
283+
while (boardImages.images.length > 6) {
284+
boardImages.images.shift();
285+
}
286+
AutodartsToolsBoardImages.setValue(boardImages);
287+
}
288+
} catch (error) {
289+
console.error("Failed to convert blob URL to base64:", error);
290+
}
291+
blobUrlFound = true;
292+
break; // Only process first blob URL found
293+
}
294+
}
295+
}
296+
}, 250);
297+
258298
break;
259299
}
260300
case "autodarts.boards.images": {
261-
data = data as string;
301+
break; // Temp disabled because it's not working as expected since last update
302+
data = data as any;
262303
const boardImages = await AutodartsToolsBoardImages.getValue();
304+
const imageUrl = `https://boards.ws.autodarts.io${(data as any).url as string}`;
263305

264-
boardImages.images.push(data as string);
265-
while (boardImages.images.length > 6) {
266-
boardImages.images.shift();
306+
// Check for duplicates before adding
307+
if (!boardImages.images.includes(imageUrl)) {
308+
boardImages.images.push(imageUrl);
309+
while (boardImages.images.length > 6) {
310+
boardImages.images.shift();
311+
}
312+
AutodartsToolsBoardImages.setValue(boardImages);
267313
}
268-
AutodartsToolsBoardImages.setValue(boardImages);
269314

270315
break;
271316
}

0 commit comments

Comments
 (0)