diff --git a/src/engines/pimeyes.js b/src/engines/pimeyes.js index 843fca0..bef1a88 100644 --- a/src/engines/pimeyes.js +++ b/src/engines/pimeyes.js @@ -23,26 +23,31 @@ async function search({session, search, image, storageIds}) { input.dispatchEvent(new Event('change')); - const searchButton = await findNode('.start-search-inner > button'); - - if (searchButton.classList.contains('disabled')) { - await findNode('.permissions input[type=checkbox]'); + const searchButton = await findNode('.start-search-inner > button', { + throwError: false + }); - for (const checkbox of document.querySelectorAll( - '.permissions input[type=checkbox]' - )) { - if (!checkbox.checked) { - checkbox.click(); + // button is missing when no faces were detected + if (searchButton) { + if (searchButton.classList.contains('disabled')) { + await findNode('.permissions input[type=checkbox]'); + + for (const checkbox of document.querySelectorAll( + '.permissions input[type=checkbox]' + )) { + if (!checkbox.checked) { + checkbox.click(); + } } - } - ( - await findNode('.start-search-inner > button:not(.disabled)', { - observerOptions: {attributes: true, attributeFilter: ['class']} - }) - ).click(); - } else { - searchButton.click(); + ( + await findNode('.start-search-inner > button:not(.disabled)', { + observerOptions: {attributes: true, attributeFilter: ['class']} + }) + ).click(); + } else { + searchButton.click(); + } } } diff --git a/src/utils/common.js b/src/utils/common.js index 60c4126..965998b 100644 --- a/src/utils/common.js +++ b/src/utils/common.js @@ -433,7 +433,9 @@ async function getPlatform({fallback = true} = {}) { })); } catch (err) { if (fallback) { - ({os, arch} = await browser.runtime.sendMessage({ + ({ + response: {os, arch} + } = await browser.runtime.sendMessage({ id: 'sendNativeMessage', message: {id: 'getPlatform'} })); @@ -520,13 +522,11 @@ async function shareFiles(files) { } async function isAndroid() { - const {os} = await getPlatform(); - return os === 'android'; + return (await getPlatform()).isAndroid; } async function isMobile() { - const {os} = await getPlatform(); - return ['android', 'ios', 'ipados'].includes(os); + return (await getPlatform()).isMobile; } function getDarkColorSchemeQuery() {