-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpopup.js
More file actions
32 lines (29 loc) · 1.26 KB
/
Copy pathpopup.js
File metadata and controls
32 lines (29 loc) · 1.26 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
document.addEventListener('DOMContentLoaded', () => {
const events = [
'abort', 'blur', 'change', 'click', 'dblclick', 'error', 'focus', 'focusin', 'focusout',
'input', 'keydown', 'keypress', 'keyup', 'load', 'mousedown', 'mouseenter', 'mouseleave',
'mousemove', 'mouseout', 'mouseover', 'mouseup', 'resize', 'scroll', 'select', 'submit',
'unload', 'wheel'
];
const checkboxGroup = document.querySelector('.checkbox-group');
events.forEach(event => {
const label = document.createElement('label');
label.innerHTML = `<input type="checkbox" id="${event}"> ${event}`;
checkboxGroup.appendChild(label);
});
document.getElementById('apply').addEventListener('click', () => {
chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => {
events.forEach(event => {
const checkbox = document.getElementById(event);
const enable = checkbox.checked;
chrome.tabs.sendMessage(tabs[0].id, { action: 'toggleEvent', event: event, enable: enable }, (response) => {
if (chrome.runtime.lastError) {
console.error(chrome.runtime.lastError.message);
} else {
console.log(response.status);
}
});
});
});
});
});