-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpopup.js
More file actions
34 lines (31 loc) · 1.11 KB
/
popup.js
File metadata and controls
34 lines (31 loc) · 1.11 KB
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
document.addEventListener('DOMContentLoaded', function() {
const stopButton = document.getElementById('stopButton');
const status = document.getElementById('status');
// Handle stop button click
stopButton.addEventListener('click', function() {
// Get current active tab
chrome.tabs.query({ active: true, currentWindow: true }, function(tabs) {
if (tabs[0]) {
// Send message to content script to stop reading
chrome.tabs.sendMessage(tabs[0].id, { action: 'stopReading' }, function(response) {
if (chrome.runtime.lastError) {
showStatus('Error: ' + chrome.runtime.lastError.message, 'error');
} else if (response && response.success) {
showStatus('Reading stopped', 'success');
} else {
showStatus('No active reading to stop', 'error');
}
});
}
});
});
function showStatus(message, type) {
status.textContent = message;
status.className = type;
// Clear status after 3 seconds
setTimeout(() => {
status.textContent = '';
status.className = '';
}, 3000);
}
});