-
Notifications
You must be signed in to change notification settings - Fork 3
/
popup.js
36 lines (30 loc) · 1.26 KB
/
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
26
27
28
29
30
31
32
33
34
35
36
document.addEventListener('DOMContentLoaded', function() {
var status = document.getElementById('status');
// Set default value
status.textContent = 'Injected: No';
// Add event listener to inject button
document.getElementById('inject').addEventListener('click', function() {
var url = document.getElementById('url').value;
if (url) {
if (url.endsWith('/')) {
localStorage.setItem('injected_url', url + "worksheets/search.html");
status.textContent = 'Injected: Yes';
chrome.runtime.sendMessage({status: 'yes'});
} else {
localStorage.setItem('injected_url', url + "/worksheets/search.html");
status.textContent = 'Injected: Yes';
chrome.runtime.sendMessage({status: 'yes'});
}
}
});
// Add event listener to remove button
document.getElementById("uninject").addEventListener("click", function () {
localStorage.removeItem("injected_url");
status.innerText = "Injected: No";
chrome.runtime.sendMessage({status: 'no'});
});
// Check if injected URL is set
if (localStorage.getItem('injected_url')) {
status.textContent = 'Injected: Yes';
}
});