|
275 | 275 | width: 100%;
|
276 | 276 | }
|
277 | 277 | #toggle-panel {
|
278 |
| - position: fixed; |
279 |
| - top: 10px; |
280 |
| - right: 115px; |
281 | 278 | z-index: 10000;
|
282 | 279 | color: white;
|
283 | 280 | padding: 5px;
|
|
289 | 286 | width: 43px;
|
290 | 287 | border-radius: 100px;
|
291 | 288 | }
|
292 |
| - #toggle-panel:hover { |
293 |
| - background-color: #fff; |
294 |
| - border-radius: 100px; |
| 289 | + #toggle-button:hover { |
| 290 | + background-color: rgba(255,255,255,0.1); |
| 291 | + border-radius: 50%; |
295 | 292 | opacity: 1 !important;
|
296 | 293 | }
|
297 | 294 | #icon-menu-settings {
|
298 | 295 | width: 24px;
|
299 | 296 | height: 24px;
|
| 297 | + padding: 7px; |
| 298 | + margin-right: 5px; |
300 | 299 | cursor: pointer;
|
301 | 300 | user-select: none;
|
302 | 301 | }
|
|
451 | 450 | .containerButtons > button:hover {
|
452 | 451 | cursor: pointer;
|
453 | 452 | }
|
454 |
| - #container.ytd-masthead { |
455 |
| - height: 56px; |
456 |
| - padding: 0 16px; |
457 |
| - display: flexbox; |
458 |
| - display: flex; |
459 |
| - flex-direction: row; |
460 |
| - align-items: center; |
461 |
| - justify-content: start; |
462 |
| - } |
| 453 | + |
463 | 454 | body {
|
464 | 455 | padding: 0;
|
465 | 456 | margin: 0;
|
|
1054 | 1045 | <label>
|
1055 | 1046 | <input type="checkbox" id="translation-toggle"> Translate comments / Reload page
|
1056 | 1047 | </label>
|
| 1048 | + </div> |
| 1049 | + <div class="enhancement-option"> |
| 1050 | + <label> |
| 1051 | + <input type="checkbox" id="avatars-toggle"> Download avatars / Reload page |
| 1052 | + </label> |
1057 | 1053 | </div>
|
1058 | 1054 | <div class="enhancement-option">
|
1059 | 1055 | <label>
|
|
1226 | 1222 | <label>
|
1227 | 1223 | <input type="checkbox" id="translation-toggle"> Translate comments / Reload page
|
1228 | 1224 | </label>
|
| 1225 | + </div> |
| 1226 | + <div class="enhancement-option"> |
| 1227 | + <label> |
| 1228 | + <input type="checkbox" id="avatars-toggle"> Download avatars / Reload page |
| 1229 | + </label> |
1229 | 1230 | </div>
|
1230 | 1231 | <div class="enhancement-option">
|
1231 | 1232 | <label>
|
|
1349 | 1350 |
|
1350 | 1351 | panel.innerHTML = panelHTML;
|
1351 | 1352 | $ap(panel);
|
1352 |
| - // Create toggle button |
1353 |
| - const toggleButton = $cl('div'); |
1354 |
| - toggleButton.id = 'toggle-panel'; |
1355 |
| - const icon = $cl('img'); |
1356 |
| - icon.id = 'icon-menu-settings'; |
1357 |
| - icon.src = |
1358 |
| - 'https://cdn.iconscout.com/icon/premium/png-512-thumb/settings-782-1095915.png?f=webp&w=256'; |
1359 | 1353 |
|
1360 |
| - toggleButton.appendChild(icon); |
1361 | 1354 |
|
1362 |
| - // Add panel and toggle button to the page |
1363 |
| - $ap(panel); |
1364 |
| - $ap(toggleButton); |
| 1355 | + function addIcon() { |
| 1356 | + const topBar = $e('ytd-topbar-menu-button-renderer'); |
| 1357 | + if (!topBar || $id('icon-menu-settings')) return; |
| 1358 | + |
| 1359 | + const toggleButton = $cl('div'); |
| 1360 | + toggleButton.id = 'toggle-button'; |
| 1361 | + |
| 1362 | + const icon = $cl('img'); |
| 1363 | + icon.id = 'icon-menu-settings'; |
| 1364 | + icon.src = 'https://cdn.iconscout.com/icon/premium/png-512-thumb/settings-782-1095915.png?f=webp&w=100'; |
| 1365 | + |
| 1366 | + toggleButton.appendChild(icon); |
| 1367 | + topBar.parentElement.insertBefore(toggleButton, topBar); |
| 1368 | + // Toggle panel visibility |
| 1369 | + let openMenu = false; |
| 1370 | + toggleButton.addEventListener('click', () => { |
| 1371 | + openMenu = !openMenu; |
| 1372 | + // openMenu |
| 1373 | + // ? (toggleButton.style.backgroundColor = '#f00') |
| 1374 | + // : (toggleButton.style.backgroundColor = 'transparent'); |
| 1375 | + panel.style.display = panel.style.display === 'none' ? 'block' : 'none'; |
| 1376 | + }); |
| 1377 | + |
| 1378 | + |
| 1379 | + } |
1365 | 1380 |
|
1366 |
| - // Toggle panel visibility |
| 1381 | + |
| 1382 | + addIcon(); |
1367 | 1383 | let openMenu = false;
|
1368 |
| - toggleButton.addEventListener('click', () => { |
1369 |
| - openMenu = !openMenu; |
1370 |
| - // openMenu |
1371 |
| - // ? (toggleButton.style.backgroundColor = '#f00') |
1372 |
| - // : (toggleButton.style.backgroundColor = 'transparent'); |
1373 |
| - panel.style.display = panel.style.display === 'none' ? 'block' : 'none'; |
1374 |
| - }); |
1375 | 1384 |
|
1376 | 1385 | const close_menu_settings = $e('.close_menu_settings');
|
1377 |
| - close_menu_settings.addEventListener('click', () => { |
1378 |
| - openMenu = !openMenu; |
1379 |
| - panel.style.display = panel.style.display === 'none' ? 'block' : 'none'; |
1380 |
| - }); |
| 1386 | + close_menu_settings.addEventListener('click', () => { |
| 1387 | + openMenu = !openMenu; |
| 1388 | + panel.style.display = panel.style.display === 'none' ? 'block' : 'none'; |
| 1389 | + }); |
| 1390 | + |
| 1391 | + // $ap(toggleButton); |
| 1392 | + |
| 1393 | + |
1381 | 1394 |
|
1382 | 1395 |
|
1383 | 1396 | // Tab functionality
|
|
1417 | 1430 | dislikes: $id('dislikes-toggle').checked,
|
1418 | 1431 | themes: $id('themes-toggle').checked,
|
1419 | 1432 | translation: $id('translation-toggle').checked,
|
| 1433 | + avatars: $id('avatars-toggle').checked, |
1420 | 1434 | reverseMode: $id('reverse-mode-toggle').checked,
|
1421 | 1435 | hideComments: $id('hide-comments-toggle').checked,
|
1422 | 1436 | hideSidebar: $id('hide-sidebar-toggle').checked,
|
|
1455 | 1469 | $id('dislikes-toggle').checked = settings.dislikes || true;
|
1456 | 1470 | $id('themes-toggle').checked = settings.themes || false;
|
1457 | 1471 | $id('translation-toggle').checked = settings.translation || false;
|
| 1472 | + $id('avatars-toggle').checked = settings.avatars || false; |
1458 | 1473 | $id('reverse-mode-toggle').checked = settings.reverseMode || false;
|
1459 | 1474 | $id('hide-comments-toggle').checked = settings.hideComments || false;
|
1460 | 1475 | $id('hide-sidebar-toggle').checked = settings.hideSidebar || false;
|
|
1513 | 1528 | dislikes: $id('dislikes-toggle').checked,
|
1514 | 1529 | themes: $id('themes-toggle').checked,
|
1515 | 1530 | translation: $id('translation-toggle').checked,
|
| 1531 | + avatars: $id('avatars-toggle').checked, |
1516 | 1532 | reverseMode: $id('reverse-mode-toggle').checked,
|
1517 | 1533 | hideComments: $id('hide-comments-toggle').checked,
|
1518 | 1534 | hideSidebar: $id('hide-sidebar-toggle').checked,
|
|
1889 | 1905 | function checkScroll () {
|
1890 | 1906 | const avatars = $m('#author-thumbnail-button #img.style-scope.yt-img-shadow');
|
1891 | 1907 |
|
1892 |
| - if (avatars.length > 0) { |
| 1908 | + if (avatars.length > 0 && settings.avatars) { |
1893 | 1909 | limpiarHTML('.yt-image-avatar-download');
|
1894 | 1910 | agregarBotonesDescarga();
|
1895 | 1911 | }
|
|
1978 | 1994 |
|
1979 | 1995 | window.open(classicUrl, '_blank');
|
1980 | 1996 |
|
1981 |
| - const videoElement = document.querySelector('video'); |
1982 |
| - if (videoElement) { |
1983 |
| - videoElement.pause(); |
1984 |
| - } else { |
1985 |
| - console.warn('No se encontró el elemento de video'); |
1986 |
| - } |
| 1997 | + $e('video.video-stream.html5-main-video').pause(); |
| 1998 | + |
1987 | 1999 | };
|
1988 | 2000 |
|
1989 | 2001 |
|
1990 | 2002 |
|
1991 | 2003 | const createButton = () => {
|
1992 |
| - const button = document.createElement('button'); |
| 2004 | + const button = $cl('button'); |
1993 | 2005 | button.classList.add(BUTTON_CLASS);
|
1994 | 2006 | button.innerHTML = '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="icon icon-tabler icons-tabler-outline icon-tabler-screen-share"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M21 12v3a1 1 0 0 1 -1 1h-16a1 1 0 0 1 -1 -1v-10a1 1 0 0 1 1 -1h9" /><path d="M7 20l10 0" /><path d="M9 16l0 4" /><path d="M15 16l0 4" /><path d="M17 4h4v4" /><path d="M16 9l5 -5" /></svg>';
|
1995 | 2007 | button.title = 'Classic mode';
|
|
2001 | 2013 | const isShortsPage = document.location.pathname.startsWith('/shorts');
|
2002 | 2014 |
|
2003 | 2015 | if (isShortsPage) {
|
2004 |
| - document.querySelectorAll('#actions').forEach(actionsContainer => { |
| 2016 | + $m('#actions').forEach(actionsContainer => { |
2005 | 2017 | if (!actionsContainer.querySelector(`.${BUTTON_CLASS}`)) {
|
2006 | 2018 | actionsContainer.prepend(createButton());
|
2007 | 2019 | }
|
2008 | 2020 | });
|
2009 | 2021 | } else {
|
2010 |
| - document.querySelectorAll(`.${BUTTON_CLASS}`).forEach(button => button.remove()); |
| 2022 | + $m(`.${BUTTON_CLASS}`).forEach(button => button.remove()); |
2011 | 2023 | }
|
2012 | 2024 | };
|
2013 | 2025 |
|
2014 | 2026 | const observeDOM = () => {
|
2015 | 2027 | const observer = new MutationObserver(() => {
|
2016 | 2028 | insertButtons();
|
| 2029 | + addIcon(); |
| 2030 | + // obs.disconnect(); |
2017 | 2031 | });
|
2018 | 2032 | observer.observe(document.body, {
|
2019 | 2033 | childList: true,
|
|
2151 | 2165 | // Evita duplicar el evento
|
2152 | 2166 | if (!bufferVideo.dataset.listenerAdded) {
|
2153 | 2167 | bufferVideo.addEventListener("click", () => {
|
2154 |
| - const video = document.querySelector("video"); |
| 2168 | + const video = $e("video.video-stream.html5-main-video"); |
2155 | 2169 |
|
2156 | 2170 | if (!video) {
|
2157 | 2171 | console.log("No se encontró el video en la página.");
|
|
2167 | 2181 | video.dispatchEvent(event);
|
2168 | 2182 |
|
2169 | 2183 | setTimeout(() => {
|
2170 |
| - const option = document.querySelector("body > div.ytp-popup.ytp-contextmenu > div > div > div:nth-child(7)"); |
| 2184 | + const option = $e("body > div.ytp-popup.ytp-contextmenu > div > div > div:nth-child(7)"); |
2171 | 2185 | if (option) {
|
2172 | 2186 | option.click();
|
2173 | 2187 | } else {
|
|
0 commit comments