Skip to content

Commit

Permalink
feat: search on Icons8
Browse files Browse the repository at this point in the history
  • Loading branch information
dessant committed Nov 2, 2023
1 parent 90a9066 commit f6253b8
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/assets/icons/engines/icons8.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 @@ -249,6 +249,11 @@
"description": "Name of the search engine."
},

"engineName_icons8": {
"message": "Icons8",
"description": "Name of the search engine."
},

"engineName_allEngines": {
"message": "all search engines",
"description": "Name of the search engine."
Expand Down Expand Up @@ -510,6 +515,11 @@
"description": "Title of the menu item."
},

"menuItemTitle_icons8": {
"message": "Icons8",
"description": "Title of the menu item."
},

"menuItemTitle_allEngines": {
"message": "All search engines",
"description": "Title of the menu item."
Expand Down Expand Up @@ -791,6 +801,11 @@
"description": "Title of the option."
},

"optionTitle_icons8": {
"message": "Icons8",
"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/icons8.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 = 'icons8';

async function search({session, search, image, storageIds}) {
(await findNode('button.search-autocomplete__img-trigger')).click();

const inputSelector = 'input#file-input';
const input = await findNode(inputSelector);

await setFileInputData(inputSelector, input, image);

await sendReceipt(storageIds);

input.dispatchEvent(new Event('input'));
}

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 @@ -49,7 +49,8 @@
"20230601115626_add_kagi",
"20230624145626_add_search_engines",
"20230716121432_add_freepik",
"20231009185955_remove_unsplash"
"20231009185955_remove_unsplash",
"20231102164602_add_icons8"
],
"sync": []
}
Expand Down
20 changes: 20 additions & 0 deletions src/storage/revisions/local/20231102164602_add_icons8.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const message = 'Add Icons8';

const revision = '20231102164602_add_icons8';

async function upgrade() {
const changes = {};
const {engines, disabledEngines} = await browser.storage.local.get([
'engines',
'disabledEngines'
]);
const newEngines = ['icons8'];

changes.engines = engines.concat(newEngines);
changes.disabledEngines = disabledEngines.concat(newEngines);

changes.storageVersion = revision;
return browser.storage.local.set(changes);
}

export {message, revision, upgrade};
12 changes: 10 additions & 2 deletions src/utils/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,12 @@ const engines = {
target: 'https://www.freepik.com/search',
isExec: true
}
},
icons8: {
image: {
target: 'https://icons8.com/',
isExec: true
}
}
};

Expand Down Expand Up @@ -614,7 +620,8 @@ const webpEngineSupport = [
'haveibeentrained',
'enterpix',
'immerse',
'clipretrieval'
'clipretrieval',
'icons8'
];

// Search engines only support the image format in compatible browsers.
Expand Down Expand Up @@ -679,7 +686,8 @@ const maxImageUploadSize = {
enterpix: {ui: 5 * 1024 * 1024},
immerse: {ui: 10 * 1024 * 1024},
clipretrieval: {ui: 15 * 1024 * 1024},
freepik: {ui: 60 * 1024 * 1024}
freepik: {ui: 60 * 1024 * 1024},
icons8: {ui: 5 * 1024 * 1024}
};

const chromeDesktopUA =
Expand Down

0 comments on commit f6253b8

Please sign in to comment.