-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpopup.js
28 lines (20 loc) · 1.04 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
document.addEventListener('DOMContentLoaded', function () {
let headerName = document.getElementById('headerName');
let headerValue = document.getElementById('headerValue');
let notification = document.getElementById('notification');
let saveButton = document.getElementById('saveButton');
chrome.runtime.sendMessage({ action: 'getCurrentRule' }, function (response) {
console.log("Response:" + JSON.stringify(response));
headerName.value = response.headerName;
headerValue.value = response.headerValue;
});
// Save button click event
saveButton.addEventListener('click', function () {
var newHeaderName = headerName.value;
var newHeaderValue = headerValue.value;
// Notify background script to update the rule with the new header value
chrome.runtime.sendMessage({ action: 'updateRule', headerName: newHeaderName, headerValue: newHeaderValue }, function (response) {
notification.hidden = false;
});
});
});