-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpopup.js
More file actions
58 lines (45 loc) · 1.5 KB
/
popup.js
File metadata and controls
58 lines (45 loc) · 1.5 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// FONT CHANGE
const fontSelect = document.getElementById('font-select');
fontSelect.addEventListener('change', function () {
const selectedFont = this.value;
chrome.storage.sync.set({ selectedFont });
chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => {
chrome.tabs.sendMessage(tabs[0].id, {
action: 'changeFont',
font: selectedFont
});
});
});
// Load saved font
chrome.storage.sync.get('selectedFont', ({ selectedFont }) => {
if (selectedFont) {
fontSelect.value = selectedFont;
}
});
// SHORTS TOGGLE (NEW SWITCH)
const toggleSwitch = document.getElementById('toggleSwitch');
// Load initial state
chrome.storage.sync.get('shortsHidden', ({ shortsHidden }) => {
toggleSwitch.checked = !!shortsHidden;
});
// On toggle change
toggleSwitch.addEventListener('change', () => {
const isEnabled = toggleSwitch.checked;
chrome.storage.sync.set({ shortsHidden: isEnabled });
chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => {
chrome.tabs.sendMessage(tabs[0].id, {
action: isEnabled ? 'hideShorts' : 'showShorts'
});
});
});
// ELEMENT PICKER FEATURE
const pickBtn = document.getElementById('pick-element');
if (pickBtn) {
pickBtn.addEventListener('click', () => {
chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => {
chrome.tabs.sendMessage(tabs[0].id, {
action: 'enablePicker'
});
});
});
}