From 25d0a4eb5b18e61c9757ab8e25a84a5293187347 Mon Sep 17 00:00:00 2001 From: sxwxs Date: Sat, 6 Jun 2020 10:38:40 +0800 Subject: [PATCH] Fix bug in testImage --- scripts/detect_headless.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/scripts/detect_headless.js b/scripts/detect_headless.js index d75d749..0ff360d 100644 --- a/scripts/detect_headless.js +++ b/scripts/detect_headless.js @@ -215,10 +215,13 @@ function testImage(resultBlock) { body.appendChild(image); image.onerror = function(){ + resultBlock.parentElement.classList.remove("undefined"); + if(image.width === 0 && image.height === 0) + resultBlock.parentElement.classList.add("headless"); + else + resultBlock.parentElement.classList.add("headful"); + writeToBlock(resultBlock, `Broken image has width ${image.width} and height ${image.height}`); - if(image.width === 0 && image.height === 0) - return HEADLESS; - return HEADFUL; } }