-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsketch.js
36 lines (29 loc) · 964 Bytes
/
sketch.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
console.log(chrome);
console.log(chrome.extension);
console.log(chrome.extension.getBackgroundPage());
console.log(chrome.extension.getBackgroundPage().word);
let bgpage = chrome.extension.getBackgroundPage();
let word = bgpage.word;
//createP(word);
const data = JSON.stringify({
text: word,
num_sentences: 2
});
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function() {
if (this.readyState === this.DONE) {
console.log(this.responseText);
var summary = this.responseText;
document.getElementById("summary").innerHTML=summary;
}
});
document.write(word);
xhr.open("POST", "https://gpt-summarization.p.rapidapi.com/summarize");
xhr.setRequestHeader("content-type", "application/json");
xhr.setRequestHeader(
"x-rapidapi-key",
"e9bb7a8714mshb718c77ffb4594cp1712b3jsn315e431a60cd"
);
xhr.setRequestHeader("x-rapidapi-host", "gpt-summarization.p.rapidapi.com");
xhr.send(data);