-
-
Notifications
You must be signed in to change notification settings - Fork 198
/
istock.js
34 lines (25 loc) · 844 Bytes
/
istock.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import {findNode, runOnce, sleep} from 'utils/common';
import {setFileInputData, initSearch, sendReceipt} from 'utils/engines';
const engine = 'istock';
async function search({session, search, image, storageIds}) {
// wait for search service to load
await findNode('#onetrust-consent-sdk');
await sleep(1000);
(
await Promise.race([
findNode('button[class*="SearchByImageButton"]'),
findNode('button[data-testid="search-by-image-button"]') // new layout
])
).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();
}