-
-
Notifications
You must be signed in to change notification settings - Fork 198
/
pixta.js
39 lines (29 loc) · 974 Bytes
/
pixta.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
35
36
37
38
39
import {findNode, runOnce} from 'utils/common';
import {setFileInputData, initSearch, sendReceipt} from 'utils/engines';
const engine = 'pixta';
async function search({session, search, image, storageIds}) {
const mobileLayout = window.matchMedia('(max-width: 768px)').matches;
if (mobileLayout) {
(await findNode('div.global-header-sp i.fa-search')).click();
(
await findNode('.global-search-form-sp__search-by-image-btn i.fa-camera')
).click();
} else {
(
await findNode('div.search-image-button.search-image-button--top')
).click();
}
const inputSelector = mobileLayout
? 'input#upload-photo[type="file"]'
: 'input#image[type="file"]';
const input = await findNode(inputSelector);
await setFileInputData(inputSelector, input, image);
await sendReceipt(storageIds);
input.dispatchEvent(new Event('change'));
}
function init() {
initSearch(search, engine, taskId);
}
if (runOnce('search')) {
init();
}