-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpopup.js
25 lines (22 loc) · 856 Bytes
/
popup.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
document.getElementById('outputButton').addEventListener('click', async () => {
let [tab] = await chrome.tabs.query({ active: true, currentWindow: true });
chrome.scripting.executeScript({
target: { tabId: tab.id },
func: getPageText,
}, (results) => {
document.getElementById('textArea').value = results[0].result;
});
});
document.getElementById('copyButton').addEventListener('click', async () => {
let text = document.getElementById('textArea').value;
await navigator.clipboard.writeText(text);
document.getElementById('message').innerText = 'Text copied to clipboard!';
setTimeout(() => {
document.getElementById('message').innerText = '';
}, 2000);
});
function getPageText() {
// Get all text content from the page
let text = document.body.innerText;
return text;
}