From 4d6d5548424ff236ee681305df005de5e7e96f56 Mon Sep 17 00:00:00 2001 From: dessant Date: Mon, 24 Jun 2024 19:29:17 +0300 Subject: [PATCH] fix: remove broken search engines Closes #313. --- src/assets/icons/engines/clipretrieval.svg | 3 - src/assets/icons/engines/enterpix.svg | 18 ------ src/assets/icons/engines/haveibeentrained.svg | 12 ---- src/assets/icons/engines/immerse.svg | 7 --- src/assets/locales/en/messages.json | 60 ------------------- src/engines/clipretrieval.js | 25 -------- src/engines/enterpix.js | 29 --------- src/engines/haveibeentrained.js | 23 ------- src/engines/immerse.js | 28 --------- src/storage/config.json | 7 ++- .../20240624161944_remove_search_engines.js | 30 ++++++++++ src/utils/data.js | 39 +----------- 12 files changed, 36 insertions(+), 245 deletions(-) delete mode 100644 src/assets/icons/engines/clipretrieval.svg delete mode 100644 src/assets/icons/engines/enterpix.svg delete mode 100644 src/assets/icons/engines/haveibeentrained.svg delete mode 100644 src/assets/icons/engines/immerse.svg delete mode 100644 src/engines/clipretrieval.js delete mode 100644 src/engines/enterpix.js delete mode 100644 src/engines/haveibeentrained.js delete mode 100644 src/engines/immerse.js create mode 100644 src/storage/revisions/local/20240624161944_remove_search_engines.js diff --git a/src/assets/icons/engines/clipretrieval.svg b/src/assets/icons/engines/clipretrieval.svg deleted file mode 100644 index 542c751..0000000 --- a/src/assets/icons/engines/clipretrieval.svg +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/src/assets/icons/engines/enterpix.svg b/src/assets/icons/engines/enterpix.svg deleted file mode 100644 index 65b59bb..0000000 --- a/src/assets/icons/engines/enterpix.svg +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/src/assets/icons/engines/haveibeentrained.svg b/src/assets/icons/engines/haveibeentrained.svg deleted file mode 100644 index 66bd081..0000000 --- a/src/assets/icons/engines/haveibeentrained.svg +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - diff --git a/src/assets/icons/engines/immerse.svg b/src/assets/icons/engines/immerse.svg deleted file mode 100644 index dfaf506..0000000 --- a/src/assets/icons/engines/immerse.svg +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/src/assets/locales/en/messages.json b/src/assets/locales/en/messages.json index d073dcd..6d6c118 100644 --- a/src/assets/locales/en/messages.json +++ b/src/assets/locales/en/messages.json @@ -224,26 +224,6 @@ "description": "Name of the search engine." }, - "engineName_haveibeentrained": { - "message": "Have I Been Trained?", - "description": "Name of the search engine." - }, - - "engineName_enterpix": { - "message": "Enterpix", - "description": "Name of the search engine." - }, - - "engineName_immerse": { - "message": "Immerse", - "description": "Name of the search engine." - }, - - "engineName_clipretrieval": { - "message": "Clip Retrieval", - "description": "Name of the search engine." - }, - "engineName_freepik": { "message": "Freepik", "description": "Name of the search engine." @@ -490,26 +470,6 @@ "description": "Title of the menu item." }, - "menuItemTitle_haveibeentrained": { - "message": "Have I Been Trained?", - "description": "Title of the menu item." - }, - - "menuItemTitle_enterpix": { - "message": "Enterpix", - "description": "Title of the menu item." - }, - - "menuItemTitle_immerse": { - "message": "Immerse", - "description": "Title of the menu item." - }, - - "menuItemTitle_clipretrieval": { - "message": "Clip Retrieval", - "description": "Title of the menu item." - }, - "menuItemTitle_freepik": { "message": "Freepik", "description": "Title of the menu item." @@ -776,26 +736,6 @@ "description": "Title of the option." }, - "optionTitle_haveibeentrained": { - "message": "Have I Been Trained?", - "description": "Title of the option." - }, - - "optionTitle_enterpix": { - "message": "Enterpix", - "description": "Title of the option." - }, - - "optionTitle_immerse": { - "message": "Immerse", - "description": "Title of the option." - }, - - "optionTitle_clipretrieval": { - "message": "Clip Retrieval", - "description": "Title of the option." - }, - "optionTitle_freepik": { "message": "Freepik", "description": "Title of the option." diff --git a/src/engines/clipretrieval.js b/src/engines/clipretrieval.js deleted file mode 100644 index f052068..0000000 --- a/src/engines/clipretrieval.js +++ /dev/null @@ -1,25 +0,0 @@ -import {findNode, runOnce} from 'utils/common'; -import {setFileInputData, initSearch, sendReceipt} from 'utils/engines'; - -const engine = 'clipretrieval'; - -async function search({session, search, image, storageIds}) { - const inputSelector = 'input[type=file]'; - const input = await findNode(inputSelector, { - rootNode: (await findNode('clip-front')).shadowRoot - }); - - await setFileInputData(inputSelector, input, image); - - await sendReceipt(storageIds); - - input.dispatchEvent(new Event('change')); -} - -function init() { - initSearch(search, engine, taskId); -} - -if (runOnce('search')) { - init(); -} diff --git a/src/engines/enterpix.js b/src/engines/enterpix.js deleted file mode 100644 index 3200f07..0000000 --- a/src/engines/enterpix.js +++ /dev/null @@ -1,29 +0,0 @@ -import {findNode, runOnce} from 'utils/common'; -import {setFileInputData, initSearch, sendReceipt} from 'utils/engines'; - -const engine = 'enterpix'; - -async function search({session, search, image, storageIds}) { - ( - await findNode( - '.mt-8 > div:nth-child(1) > div:nth-child(1) > div:nth-child(3) > button:nth-child(1)' - ) - ).click(); - - const inputSelector = 'input[type=file]'; - const input = await findNode(inputSelector); - - await setFileInputData(inputSelector, input, image); - - await sendReceipt(storageIds); - - input.dispatchEvent(new Event('change', {bubbles: true})); -} - -function init() { - initSearch(search, engine, taskId); -} - -if (runOnce('search')) { - init(); -} diff --git a/src/engines/haveibeentrained.js b/src/engines/haveibeentrained.js deleted file mode 100644 index 2cf1984..0000000 --- a/src/engines/haveibeentrained.js +++ /dev/null @@ -1,23 +0,0 @@ -import {findNode, runOnce} from 'utils/common'; -import {setFileInputData, initSearch, sendReceipt} from 'utils/engines'; - -const engine = 'haveibeentrained'; - -async function search({session, search, image, storageIds}) { - const inputSelector = 'input[type=file]'; - const input = await findNode(inputSelector); - - await setFileInputData(inputSelector, input, image); - - await sendReceipt(storageIds); - - input.dispatchEvent(new Event('change', {bubbles: true})); -} - -function init() { - initSearch(search, engine, taskId); -} - -if (runOnce('search')) { - init(); -} diff --git a/src/engines/immerse.js b/src/engines/immerse.js deleted file mode 100644 index 3ee7d8f..0000000 --- a/src/engines/immerse.js +++ /dev/null @@ -1,28 +0,0 @@ -import {findNode, makeDocumentVisible, runOnce, sleep} from 'utils/common'; -import {setFileInputData, initSearch, sendReceipt} from 'utils/engines'; - -const engine = 'immerse'; - -async function search({session, search, image, storageIds}) { - await sleep(1000); - - (await findNode('img.addUploadPic')).click(); - - const inputSelector = 'input[type=file]'; - const input = await findNode(inputSelector); - - await setFileInputData(inputSelector, input, image); - - await sendReceipt(storageIds); - - input.dispatchEvent(new Event('change')); -} - -function init() { - makeDocumentVisible(); - initSearch(search, engine, taskId); -} - -if (runOnce('search')) { - init(); -} diff --git a/src/storage/config.json b/src/storage/config.json index 70eb4f4..f0317f0 100755 --- a/src/storage/config.json +++ b/src/storage/config.json @@ -53,8 +53,11 @@ "20231102164602_add_icons8", "20240514170322_add_appversion", "20240529183556_update_search_engines", - "20240619180111_add_menuchangeevent" + "20240619180111_add_menuchangeevent", + "20240624161944_remove_search_engines" ], - "session": ["20240514122825_initial_version"] + "session": [ + "20240514122825_initial_version" + ] } } diff --git a/src/storage/revisions/local/20240624161944_remove_search_engines.js b/src/storage/revisions/local/20240624161944_remove_search_engines.js new file mode 100644 index 0000000..ab1e798 --- /dev/null +++ b/src/storage/revisions/local/20240624161944_remove_search_engines.js @@ -0,0 +1,30 @@ +const message = 'Remove search engines'; + +const revision = '20240624161944_remove_search_engines'; + +async function upgrade() { + const changes = {}; + const {engines, disabledEngines} = await browser.storage.local.get([ + 'engines', + 'disabledEngines' + ]); + + const removeEngines = [ + 'haveibeentrained', + 'enterpix', + 'immerse', + 'clipretrieval' + ]; + + changes.engines = engines.filter(function (item) { + return !removeEngines.includes(item); + }); + changes.disabledEngines = disabledEngines.filter(function (item) { + return !removeEngines.includes(item); + }); + + changes.storageVersion = revision; + return browser.storage.local.set(changes); +} + +export {message, revision, upgrade}; diff --git a/src/utils/data.js b/src/utils/data.js index 3c16d2b..968d5b2 100755 --- a/src/utils/data.js +++ b/src/utils/data.js @@ -330,32 +330,6 @@ const engines = { isExec: true } }, - haveibeentrained: { - url: {target: 'https://haveibeentrained.com/?url={imgUrl}'}, - image: { - target: 'https://haveibeentrained.com/', - isExec: true - } - }, - enterpix: { - image: { - target: 'https://enterpix.app/', - isExec: true - } - }, - immerse: { - url: {target: 'https://www.immerse.zone/image?url={imgUrl}'}, - image: { - target: 'https://www.immerse.zone/', - isExec: true - } - }, - clipretrieval: { - image: { - target: 'https://knn.laion.ai/', - isExec: true - } - }, freepik: { image: { target: 'https://www.freepik.com/search', @@ -391,8 +365,6 @@ const engineIconVariants = { ascii2d: ['dark'], tmview: ['dark'], pixta: ['dark'], - immerse: ['dark'], - clipretrieval: ['dark'], freepik: ['dark'] }; @@ -618,10 +590,6 @@ const webpEngineSupport = [ 'lykdat', 'googleLens', 'lexica', - 'haveibeentrained', - 'enterpix', - 'immerse', - 'clipretrieval', 'icons8' ]; @@ -635,8 +603,7 @@ const avifEngineSupport = [ 'alibabaChina', 'dreamstime', 'pond5', - 'lexica', - 'enterpix' + 'lexica' ]; const maxImageUploadSize = { @@ -683,10 +650,6 @@ const maxImageUploadSize = { googleLens: {api: 20 * 1024 * 1024}, lexica: {ui: 30 * 1024 * 1024}, kagi: {ui: 1 * 1024 * 1024}, - haveibeentrained: {ui: 10 * 1024 * 1024}, - enterpix: {ui: 5 * 1024 * 1024}, - immerse: {ui: 10 * 1024 * 1024}, - clipretrieval: {ui: 15 * 1024 * 1024}, freepik: {ui: 60 * 1024 * 1024}, icons8: {ui: 5 * 1024 * 1024} };