|
1 | 1 | function showPage(pageId) { |
2 | 2 | const pages = document.querySelectorAll('.page'); |
3 | | - const pageToShow = document.getElementById(pageId); |
4 | | - |
5 | | - if (!pageToShow) { |
6 | | - return; |
7 | | - } |
8 | 3 |
|
9 | 4 | pages.forEach((page) => { |
10 | 5 | page.style.opacity = '0'; |
11 | 6 | page.style.pointerEvents = 'none'; |
12 | 7 | page.style.position = 'absolute'; |
13 | 8 | }); |
14 | 9 |
|
15 | | - pageToShow.style.display = 'block'; |
16 | | - pageToShow.style.opacity = '1'; |
17 | | - pageToShow.style.pointerEvents = 'auto'; |
18 | | - pageToShow.style.position = 'relative'; |
| 10 | + const pageToShow = document.getElementById(pageId); |
| 11 | + |
| 12 | + if (pageToShow) { |
| 13 | + pageToShow.style.display = 'block'; |
| 14 | + setTimeout(() => { |
| 15 | + pageToShow.style.opacity = '1'; |
| 16 | + pageToShow.style.pointerEvents = 'auto'; |
| 17 | + pageToShow.style.position = 'relative'; |
| 18 | + }, 0); |
| 19 | + } |
19 | 20 | } |
20 | 21 |
|
21 | 22 | document.addEventListener('DOMContentLoaded', () => { |
22 | 23 | const startButton = document.getElementById('startButton'); |
23 | 24 | const stopButton = document.getElementById('stopButton'); |
24 | | - const messageElement = document.getElementById('message'); |
25 | 25 | const backButton = document.getElementById('backButton'); |
26 | 26 | const gridItems = document.querySelectorAll('.grid-item'); |
27 | 27 | const startButton2 = document.getElementById('startButton2'); |
28 | 28 | const stopButton2 = document.getElementById('stopButton2'); |
29 | 29 | const startButton3 = document.getElementById('startButton3'); |
30 | 30 | const stopButton3 = document.getElementById('stopButton3'); |
31 | | - const startButton4 = document.getElementById('startButton4'); |
32 | 31 | const stopButton4 = document.getElementById('stopButton4'); |
| 32 | + const startButtonCopy1 = document.getElementById('startButtonCopy1'); |
| 33 | + const startButtonCopy2 = document.getElementById('startButtonCopy2'); |
| 34 | + const startButtonCopy3 = document.getElementById('startButtonCopy3'); |
| 35 | + |
| 36 | + function hideButton(button) { |
| 37 | + button.style.display = 'none'; |
| 38 | + } |
| 39 | + |
| 40 | + function showButton(button) { |
| 41 | + button.style.display = 'block'; |
| 42 | + } |
33 | 43 |
|
34 | 44 | const toggleButtons = (startEnabled, stopEnabled) => { |
35 | | - startButton.classList.toggle('disabled', !startEnabled); |
36 | | - stopButton.classList.toggle('disabled', !stopEnabled); |
| 45 | + if (startEnabled) { |
| 46 | + showButton(startButton); |
| 47 | + startButtonCopy1.style.display = 'none'; // Hide the copy when start is enabled |
| 48 | + } else { |
| 49 | + hideButton(startButton); |
| 50 | + } |
| 51 | + |
| 52 | + if (stopEnabled) { |
| 53 | + showButton(stopButton); |
| 54 | + startButtonCopy1.style.display = 'none'; // Hide the copy when start is enabled |
| 55 | + } else { |
| 56 | + hideButton(stopButton); |
| 57 | + } |
37 | 58 | }; |
38 | 59 |
|
39 | 60 | const toggleButtons2 = (startEnabled, stopEnabled) => { |
40 | | - startButton2.classList.toggle('disabled', !startEnabled); |
41 | | - stopButton2.classList.toggle('disabled', !stopEnabled); |
| 61 | + if (startEnabled) { |
| 62 | + showButton(startButton2); |
| 63 | + startButtonCopy2.style.display = 'none'; // Hide the copy when start is enabled |
| 64 | + } else { |
| 65 | + hideButton(startButton2); |
| 66 | + } |
| 67 | + |
| 68 | + if (stopEnabled) { |
| 69 | + showButton(stopButton2); |
| 70 | + startButtonCopy2.style.display = 'none'; // Hide the copy when start is enabled |
| 71 | + |
| 72 | + } else { |
| 73 | + hideButton(stopButton2); |
| 74 | + } |
42 | 75 | }; |
43 | 76 |
|
44 | 77 | const toggleButtons3 = (startEnabled, stopEnabled) => { |
45 | | - startButton3.classList.toggle('disabled', !startEnabled); |
46 | | - stopButton3.classList.toggle('disabled', !stopEnabled); |
| 78 | + if (startEnabled) { |
| 79 | + showButton(startButton3); |
| 80 | + startButtonCopy3.style.display = 'none'; // Hide the copy when start is enabled |
| 81 | + } else { |
| 82 | + hideButton(startButton3); |
| 83 | + } |
| 84 | + |
| 85 | + if (stopEnabled) { |
| 86 | + showButton(stopButton3); |
| 87 | + startButtonCopy3.style.display = 'none'; // Hide the copy when start is enabled |
| 88 | + |
| 89 | + } else { |
| 90 | + hideButton(stopButton3); |
| 91 | + } |
47 | 92 | }; |
48 | 93 |
|
49 | | - const toggleButtons4 = (startEnabled, stopEnabled) => { |
50 | | - startButton4.classList.toggle('disabled', !startEnabled); |
| 94 | + const toggleButtons4 = (stopEnabled) => { |
51 | 95 | stopButton4.classList.toggle('disabled', !stopEnabled); |
52 | 96 | }; |
53 | 97 |
|
54 | | - toggleButtons4(false, false); |
| 98 | + toggleButtons4(false); |
55 | 99 |
|
56 | 100 | function isYouTubeFeedTab(url) { |
57 | 101 | return url.startsWith('https://www.youtube.com/feed/channels'); |
@@ -102,6 +146,18 @@ document.addEventListener('DOMContentLoaded', () => { |
102 | 146 | }); |
103 | 147 | }); |
104 | 148 |
|
| 149 | + startButtonCopy1.addEventListener("click", function () { |
| 150 | + window.open("https://www.youtube.com/feed/channels", "_blank"); |
| 151 | + }); |
| 152 | + |
| 153 | + startButtonCopy2.addEventListener("click", function () { |
| 154 | + window.open("https://www.youtube.com/playlist?list=LL", "_blank"); |
| 155 | + }); |
| 156 | + |
| 157 | + startButtonCopy3.addEventListener("click", function () { |
| 158 | + window.open("https://www.youtube.com/playlist?list=WL", "_blank"); |
| 159 | + }); |
| 160 | + |
105 | 161 | stopButton.addEventListener('click', () => { |
106 | 162 | chrome.tabs.query({ active: true, currentWindow: true }, ([activeTab]) => { |
107 | 163 | if (!stopButton.classList.contains('disabled')) { |
@@ -193,7 +249,7 @@ document.addEventListener('DOMContentLoaded', () => { |
193 | 249 | }); |
194 | 250 |
|
195 | 251 | function resetExtension() { |
196 | | - chrome.storage.local.get(['activePage', 'startButtonEnabled', 'stopButtonEnabled'], ({ activePage, startButtonEnabled, stopButtonEnabled }) => { |
| 252 | + chrome.storage.local.get(['activePage', 'startButtonEnabled', 'stopButtonEnabled'], ({ activePage }) => { |
197 | 253 | const pageToShow = activePage || 'defaultPage'; |
198 | 254 | showPage(pageToShow); |
199 | 255 | }); |
|
0 commit comments