-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
55 lines (48 loc) · 1.3 KB
/
index.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
chrome.contextMenus.create({
title: 'Text analysis',
id: 'parent',
contexts: ['selection'],
onclick: callTextAnalyzer,
});
chrome.contextMenus.create({
title: 'Send email',
id: 'email',
contexts: ['selection'],
onclick: sendEmail,
});
async function callTextAnalyzer() {
let res = await fetch('http://localhost:8000/callAnalyser', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Accept: 'application/json',
},
body: JSON.stringify({
"analyse": text,
}),
});
var obj = await res.json();
console.log(JSON.stringify(obj));
alert(JSON.stringify(obj));
}
let list = [];
document.querySelectorAll(`div[data-testid^="solid-message-bubble"]`).forEach(
(i) => list.push(i)
);
const text = list.map((val) => val.children[0].children[0]);
function sendEmail() {
var xmlRequest = new XMLHttpRequest();
var target_email = '[email protected]';
if (window.XMLHttpRequest) {
xmlRequest.open(
'POST',
`https://maker.ifttt.com/trigger/trigger_email/with/key/bf6zxKZovTXRIycFmggtoQO-me1zGm6vswN-SBBwJYr?value1=${target_email}`
);
xmlRequest.send();
xmlRequest.onreadystatechange = function () {
if (xmlRequest.readyState == 4 && xmlRequest.status == 200) {
alert('Notification sent');
}
};
}
}