-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
31 lines (26 loc) · 947 Bytes
/
app.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
import {getCurrentURL, openOptionsPage} from "./background.js";
const summarizeAndOutput = async () => {
getCurrentURL().then((url) => {
document.getElementById("title").innerHTML = url
});
document.getElementById("summary").innerHTML = "Loading..."
chrome.runtime.sendMessage({action: 'loadSummary'}, async (response) => {
displaySummary(response);
});
}
const displaySummary = (summary) => {
document.getElementById("title").innerHTML = summary.title;
document.getElementById("summary").innerHTML = summary.summary;
}
document.addEventListener('DOMContentLoaded', function () {
summarizeAndOutput().then(() => {
console.log("Summarized")
}).catch((error) => {
console.log(error)
})
document.querySelector('body').addEventListener('click', async (event) => {
if (event.target.matches('#go-to-options')) {
openOptionsPage();
}
});
});