From 380051c17bd2966a8b1406d15b3e9ae2777c4c81 Mon Sep 17 00:00:00 2001 From: dessant Date: Thu, 11 Nov 2021 11:58:22 +0200 Subject: [PATCH] feat: search on LykDat --- src/assets/icons/engines/lykdat.svg | 7 ++++++ src/assets/locales/en/messages.json | 15 +++++++++++ src/engines/lykdat.js | 23 +++++++++++++++++ src/storage/config.json | 3 ++- .../local/20211111071410_add_lykdat.js | 25 +++++++++++++++++++ src/utils/data.js | 6 +++++ 6 files changed, 78 insertions(+), 1 deletion(-) create mode 100644 src/assets/icons/engines/lykdat.svg create mode 100644 src/engines/lykdat.js create mode 100644 src/storage/revisions/local/20211111071410_add_lykdat.js diff --git a/src/assets/icons/engines/lykdat.svg b/src/assets/icons/engines/lykdat.svg new file mode 100644 index 0000000..a6944fa --- /dev/null +++ b/src/assets/icons/engines/lykdat.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/src/assets/locales/en/messages.json b/src/assets/locales/en/messages.json index fe43cf8..6c01935 100644 --- a/src/assets/locales/en/messages.json +++ b/src/assets/locales/en/messages.json @@ -239,6 +239,11 @@ "description": "Name of the search engine." }, + "engineName_lykdat": { + "message": "LykDat", + "description": "Name of the search engine." + }, + "engineName_allEngines": { "message": "all search engines", "description": "Name of the search engine." @@ -490,6 +495,11 @@ "description": "Title of the menu item." }, + "menuItemTitle_lykdat": { + "message": "LykDat", + "description": "Title of the menu item." + }, + "menuItemTitle_allEngines": { "message": "All search engines", "description": "Title of the menu item." @@ -756,6 +766,11 @@ "description": "Title of the option." }, + "optionTitle_lykdat": { + "message": "LykDat", + "description": "Title of the option." + }, + "optionTitle_searchMode": { "message": "Search mode", "description": "Title of the option." diff --git a/src/engines/lykdat.js b/src/engines/lykdat.js new file mode 100644 index 0000000..daa3ade --- /dev/null +++ b/src/engines/lykdat.js @@ -0,0 +1,23 @@ +import {findNode} from 'utils/common'; +import {setFileInputData, initSearch, sendReceipt} from 'utils/engines'; + +const engine = 'lykdat'; + +async function search({session, search, image, storageIds}) { + const inputSelector = '.top-search-image-box input[type=file]'; + const input = await findNode(inputSelector); + + await setFileInputData(inputSelector, input, image); + + await sendReceipt(storageIds); + + input.dispatchEvent(new Event('change', {bubbles: true})); + + (await findNode('.finisher button')).click(); +} + +function init() { + initSearch(search, engine, taskId); +} + +init(); diff --git a/src/storage/config.json b/src/storage/config.json index 44c833c..2e29a31 100755 --- a/src/storage/config.json +++ b/src/storage/config.json @@ -32,7 +32,8 @@ "20210919175209_add_image_sharing_options", "20210928090443_add_unsplash", "20211011114043_configure_engines", - "20211106103932_add_shein" + "20211106103932_add_shein", + "20211111071410_add_lykdat" ], "sync": [] } diff --git a/src/storage/revisions/local/20211111071410_add_lykdat.js b/src/storage/revisions/local/20211111071410_add_lykdat.js new file mode 100644 index 0000000..5c2a570 --- /dev/null +++ b/src/storage/revisions/local/20211111071410_add_lykdat.js @@ -0,0 +1,25 @@ +import browser from 'webextension-polyfill'; + +const message = 'Add LykDat'; + +const revision = '20211111071410_add_lykdat'; +const downRevision = '20211106103932_add_shein'; + +const storage = browser.storage.local; + +async function upgrade() { + const changes = {}; + const {engines, disabledEngines} = await storage.get([ + 'engines', + 'disabledEngines' + ]); + const newEngines = ['lykdat']; + + changes.engines = engines.concat(newEngines); + changes.disabledEngines = disabledEngines.concat(newEngines); + + changes.storageVersion = revision; + return storage.set(changes); +} + +export {message, revision, upgrade}; diff --git a/src/utils/data.js b/src/utils/data.js index a4cf9b7..ec55975 100755 --- a/src/utils/data.js +++ b/src/utils/data.js @@ -322,6 +322,12 @@ const engines = { target: 'https://m.shein.com/presearch', isExec: true } + }, + lykdat: { + upload: { + target: 'https://lykdat.com/', + isExec: true + } } };