-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
22 lines (19 loc) · 811 Bytes
/
script.js
File metadata and controls
22 lines (19 loc) · 811 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
document.getElementById('startSelect').addEventListener('click', (e) => {
e.preventDefault(); // Prevent the default action
chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => {
if (tabs.length > 0) {
const tab = tabs[0];
chrome.tabs.sendMessage(tab.id, { action: 'start-selection' }, (response) => {
if (chrome.runtime.lastError) {
console.error(chrome.runtime.lastError.message);
}
});
}
});
});
// Listen for messages from the content script
chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
if (message.action === 'display-text') {
document.body.innerHTML = `<pre>${message.text}</pre>`; // Display the inner text in the popup
}
});