Skip to content

Commit ce97765

Browse files
committed
Version 1.1
- New Toggle System - Better Logic
1 parent b582f7b commit ce97765

File tree

3 files changed

+96
-39
lines changed

3 files changed

+96
-39
lines changed

content-dislike.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ let items;
44

55
chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
66
if (message.action === 'startDislike') {
7-
initializeDislike();
87
startDislike();
98
} else if (message.action === 'stopDislike') {
109
stopDislike();
@@ -13,13 +12,13 @@ chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
1312

1413
function initializeDislike() {
1514
stopDislikeFlag = false;
16-
dislikeIndex = 0;
1715
items = document.querySelectorAll(
1816
`#primary ytd-playlist-video-renderer yt-icon-button.dropdown-trigger > button[aria-label]`
1917
);
2018
}
2119

2220
async function startDislike() {
21+
initializeDislike(); // Initialize the items
2322
while (!stopDislikeFlag && dislikeIndex < items.length) {
2423
await dislikeVideo();
2524
dislikeIndex++;
@@ -46,10 +45,9 @@ async function dislikeVideo() {
4645

4746
if (dropdown && dropdown.lastElementChild) {
4847
dropdown.lastElementChild.click();
49-
} else {
5048
}
5149
}
5250

5351
function sleep(ms) {
5452
return new Promise((resolve) => setTimeout(resolve, ms));
55-
}
53+
}

popup.html

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
<body>
1212
<div class="popup-container">
13-
1413
<div class="page" id="defaultPage">
1514
<div class="header">
1615
<img src="images/logo.svg" alt="Logo" width="36" height="36" class="header-icon">
@@ -41,9 +40,11 @@ <h1 class="header-title">Subscription</h1>
4140
</div>
4241
</div>
4342
<div class="separator"></div>
44-
<p id="message" class="popup-subtitle">Please go to YouTube &gt; Subscription &gt;<br> Manage to continue</p>
45-
<div id="startButton" class="custom-button start-button" disabled>Start Unsubscribing</div>
46-
<div id="stopButton" class="custom-button stop-button" disabled>Stop Unsubscribing</div>
43+
<p id="message" class="popup-subtitle">Unsubscribe from channels easily and organize your YouTube subscriptions.
44+
</p>
45+
<div id="startButton" class="custom-button start-button">Start Cleaning</div>
46+
<div id="startButtonCopy1" class="custom-button start-button">Go to Subscriptions</div>
47+
<div id="stopButton" class="custom-button stop-button">Stop Cleaning</div>
4748
</div>
4849

4950
<div class="page" id="page2">
@@ -57,9 +58,11 @@ <h1 class="header-title">Likes</h1>
5758
</div>
5859
</div>
5960
<div class="separator"></div>
60-
<p id="message2" class="popup-subtitle">Please go to YouTube &gt; Sidebar &gt;<br> Liked Videos to continue</p>
61-
<div id="startButton2" class="custom-button start-button" disabled>Start Disliking</div>
62-
<div id="stopButton2" class="custom-button stop-button" disabled>Stop Disliking</div>
61+
<p id="message2" class="popup-subtitle">Clear your 'Watch Later' playlist quickly and enjoy a clutter-free list.
62+
</p>
63+
<div id="startButton2" class="custom-button start-button">Start Cleaning</div>
64+
<div id="startButtonCopy2" class="custom-button start-button">Go to Liked Videos</div>
65+
<div id="stopButton2" class="custom-button stop-button">Stop Cleaning</div>
6366
</div>
6467

6568
<div class="page" id="page3">
@@ -73,9 +76,10 @@ <h1 class="header-title">Watch Later</h1>
7376
</div>
7477
</div>
7578
<div class="separator"></div>
76-
<p id="message3" class="popup-subtitle">Please go to YouTube &gt; Sidebar &gt;<br> Watch Later to continue</p>
77-
<div id="startButton3" class="custom-button start-button" disabled>Start Cleaning</div>
78-
<div id="stopButton3" class="custom-button stop-button" disabled>Stop Cleaning</div>
79+
<p id="message3" class="popup-subtitle">Effortlessly manage your liked videos for a more organized library.</p>
80+
<div id="startButton3" class="custom-button start-button">Start Cleaning</div>
81+
<div id="startButtonCopy3" class="custom-button start-button">Go to Watch Later</div>
82+
<div id="stopButton3" class="custom-button stop-button">Stop Cleaning</div>
7983
</div>
8084

8185
<div class="page" id="page4">
@@ -89,11 +93,10 @@ <h1 class="header-title">Advanced</h1>
8993
</div>
9094
</div>
9195
<div class="separator"></div>
92-
<p id="message4" class="popup-subtitle">Exciting updates coming soon! This tab is currently in development</p>
93-
<div id="startButton4" class="custom-button start-button" disabled>Start Cleaning</div>
94-
<div id="stopButton4" class="custom-button stop-button" disabled>Stop Cleaning</div>
96+
<p id="message4" class="popup-subtitle">Exciting updates coming soon! Stay tuned for new features and
97+
improvements.</p>
98+
<div id="stopButton4" class="custom-button stop-button" disabled>Coming Soon</div>
9599
</div>
96-
97100
</div>
98101
</body>
99102

popup.js

Lines changed: 77 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,101 @@
11
function showPage(pageId) {
22
const pages = document.querySelectorAll('.page');
3-
const pageToShow = document.getElementById(pageId);
4-
5-
if (!pageToShow) {
6-
return;
7-
}
83

94
pages.forEach((page) => {
105
page.style.opacity = '0';
116
page.style.pointerEvents = 'none';
127
page.style.position = 'absolute';
138
});
149

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+
}
1920
}
2021

2122
document.addEventListener('DOMContentLoaded', () => {
2223
const startButton = document.getElementById('startButton');
2324
const stopButton = document.getElementById('stopButton');
24-
const messageElement = document.getElementById('message');
2525
const backButton = document.getElementById('backButton');
2626
const gridItems = document.querySelectorAll('.grid-item');
2727
const startButton2 = document.getElementById('startButton2');
2828
const stopButton2 = document.getElementById('stopButton2');
2929
const startButton3 = document.getElementById('startButton3');
3030
const stopButton3 = document.getElementById('stopButton3');
31-
const startButton4 = document.getElementById('startButton4');
3231
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+
}
3343

3444
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+
}
3758
};
3859

3960
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+
}
4275
};
4376

4477
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+
}
4792
};
4893

49-
const toggleButtons4 = (startEnabled, stopEnabled) => {
50-
startButton4.classList.toggle('disabled', !startEnabled);
94+
const toggleButtons4 = (stopEnabled) => {
5195
stopButton4.classList.toggle('disabled', !stopEnabled);
5296
};
5397

54-
toggleButtons4(false, false);
98+
toggleButtons4(false);
5599

56100
function isYouTubeFeedTab(url) {
57101
return url.startsWith('https://www.youtube.com/feed/channels');
@@ -102,6 +146,18 @@ document.addEventListener('DOMContentLoaded', () => {
102146
});
103147
});
104148

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+
105161
stopButton.addEventListener('click', () => {
106162
chrome.tabs.query({ active: true, currentWindow: true }, ([activeTab]) => {
107163
if (!stopButton.classList.contains('disabled')) {
@@ -193,7 +249,7 @@ document.addEventListener('DOMContentLoaded', () => {
193249
});
194250

195251
function resetExtension() {
196-
chrome.storage.local.get(['activePage', 'startButtonEnabled', 'stopButtonEnabled'], ({ activePage, startButtonEnabled, stopButtonEnabled }) => {
252+
chrome.storage.local.get(['activePage', 'startButtonEnabled', 'stopButtonEnabled'], ({ activePage }) => {
197253
const pageToShow = activePage || 'defaultPage';
198254
showPage(pageToShow);
199255
});

0 commit comments

Comments
 (0)