-
-
Notifications
You must be signed in to change notification settings - Fork 198
/
shutterstock.js
34 lines (24 loc) · 921 Bytes
/
shutterstock.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, isMobile, runOnce} from 'utils/common';
import {setFileInputData, initSearch, sendReceipt} from 'utils/engines';
const engine = 'shutterstock';
async function search({session, search, image, storageIds}) {
if (await isMobile()) {
// some elements are loaded only after the first user interaction
window.dispatchEvent(new Event('touchstart'));
}
(await findNode('.MuiSelect-select[aria-label*="image"]')).dispatchEvent(
new MouseEvent('mousedown', {bubbles: true})
);
(await findNode('li[data-value="reverseImageSearch"]')).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();
}