Skip to content

Commit

Permalink
feat: search on LykDat
Browse files Browse the repository at this point in the history
  • Loading branch information
dessant committed Nov 11, 2021
1 parent 3f79e72 commit 380051c
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/assets/icons/engines/lykdat.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions src/assets/locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down Expand Up @@ -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."
Expand Down Expand Up @@ -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."
Expand Down
23 changes: 23 additions & 0 deletions src/engines/lykdat.js
Original file line number Diff line number Diff line change
@@ -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();
3 changes: 2 additions & 1 deletion src/storage/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": []
}
Expand Down
25 changes: 25 additions & 0 deletions src/storage/revisions/local/20211111071410_add_lykdat.js
Original file line number Diff line number Diff line change
@@ -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};
6 changes: 6 additions & 0 deletions src/utils/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,12 @@ const engines = {
target: 'https://m.shein.com/presearch',
isExec: true
}
},
lykdat: {
upload: {
target: 'https://lykdat.com/',
isExec: true
}
}
};

Expand Down

0 comments on commit 380051c

Please sign in to comment.