-
-
Notifications
You must be signed in to change notification settings - Fork 198
/
tmview.js
40 lines (30 loc) · 924 Bytes
/
tmview.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
40
import {findNode, processNode, runOnce} from 'utils/common';
import {setFileInputData, initSearch, sendReceipt} from 'utils/engines';
const engine = 'tmview';
async function search({session, search, image, storageIds}) {
// previous search may be cached
let removeImage = true;
processNode(
'.image-remove button',
function (node) {
if (node && removeImage) {
node.click();
}
},
{throwError: false}
);
const inputSelector = 'input[type=file]';
const input = await findNode(inputSelector);
removeImage = false;
await setFileInputData(inputSelector, input, image);
input.dispatchEvent(new Event('change', {bubbles: true}));
await findNode('.image-remove button');
await sendReceipt(storageIds);
(await findNode('button[data-test-id=search-button]')).click();
}
function init() {
initSearch(search, engine, taskId);
}
if (runOnce('search')) {
init();
}