|
1 | 1 | // ==UserScript== |
2 | 2 | // @name YouTube™ Classic 📺 — (Remove rounded design + Return YouTube dislikes) |
3 | | -// @version 2026.1.17.21 |
| 3 | +// @version 2026.1.17.22 |
4 | 4 | // @author Adam Lui, Magma_Craft, Anarios, JRWR, Fuim & hoothin |
5 | 5 | // @namespace https://github.com/adamlui |
6 | 6 | // @description Reverts YouTube to its classic design (before all the rounded corners & hidden dislikes) + redirects YouTube Shorts |
|
1760 | 1760 | ) |
1761 | 1761 | } |
1762 | 1762 |
|
1763 | | - function getButtons() { |
| 1763 | + function getBtns() { |
1764 | 1764 | if (isShorts()) { |
1765 | | - let elements = document.querySelectorAll( |
1766 | | - isMobile |
1767 | | - ? 'ytm-like-button-renderer' |
1768 | | - : '#like-button > ytd-like-button-renderer' |
1769 | | - ) |
1770 | | - for (let element of elements) { |
1771 | | - if (isInViewport(element)) { |
1772 | | - return element |
1773 | | - } |
1774 | | - } |
1775 | | - } |
1776 | | - if (isMobile) { |
1777 | | - return ( |
1778 | | - document.querySelector('.slim-video-action-bar-actions .segmented-buttons') ?? |
1779 | | - document.querySelector('.slim-video-action-bar-actions') |
1780 | | - ) |
1781 | | - } |
1782 | | - if (document.getElementById('menu-container')?.offsetParent == null) { |
1783 | | - return ( |
1784 | | - document.querySelector('ytd-menu-renderer.ytd-watch-metadata > div') ?? |
1785 | | - document.querySelector('ytd-menu-renderer.ytd-video-primary-info-renderer > div') |
1786 | | - ) |
1787 | | - } else { |
1788 | | - return document |
1789 | | - .getElementById('menu-container') |
1790 | | - ?.querySelector('#top-level-buttons-computed') |
| 1765 | + const elems = document.querySelectorAll(`${ !isMobile ? '#like-button > ' : '' }ytm-like-button-renderer`) |
| 1766 | + for (const elem of elems) if (isInViewport(elem)) return elem |
1791 | 1767 | } |
| 1768 | + if (isMobile) |
| 1769 | + return document.querySelector('.slim-video-action-bar-actions .segmented-buttons') |
| 1770 | + ?? document.querySelector('.slim-video-action-bar-actions') |
| 1771 | + else if (!document.getElementById('menu-container')?.offsetParent) |
| 1772 | + return document.querySelector('ytd-menu-renderer.ytd-watch-metadata > div') |
| 1773 | + ?? document.querySelector('ytd-menu-renderer.ytd-video-primary-info-renderer > div') |
| 1774 | + else |
| 1775 | + return document.getElementById('menu-container')?.querySelector('#top-level-buttons-computed') |
1792 | 1776 | } |
1793 | 1777 |
|
1794 | 1778 | function getLikeButton() { |
1795 | | - return getButtons().children[0].tagName == |
| 1779 | + return getBtns().children[0].tagName == |
1796 | 1780 | 'YTD-SEGMENTED-LIKE-DISLIKE-BUTTON-RENDERER' |
1797 | | - ? getButtons().children[0].children[0] |
1798 | | - : getButtons().children[0] |
| 1781 | + ? getBtns().children[0].children[0] |
| 1782 | + : getBtns().children[0] |
1799 | 1783 | } |
1800 | 1784 |
|
1801 | 1785 | function getLikeTextContainer() { |
|
1807 | 1791 | } |
1808 | 1792 |
|
1809 | 1793 | function getDislikeButton() { |
1810 | | - return getButtons().children[0].tagName == |
| 1794 | + return getBtns().children[0].tagName == |
1811 | 1795 | 'YTD-SEGMENTED-LIKE-DISLIKE-BUTTON-RENDERER' |
1812 | | - ? getButtons().children[0].children[1] |
1813 | | - : getButtons().children[1] |
| 1796 | + ? getBtns().children[0].children[1] |
| 1797 | + : getBtns().children[1] |
1814 | 1798 | } |
1815 | 1799 |
|
1816 | 1800 | function getDislikeTextContainer() { |
|
1864 | 1848 |
|
1865 | 1849 | function setLikes(likesCount) { |
1866 | 1850 | if (isMobile) { |
1867 | | - getButtons().children[0].querySelector('.button-renderer-text').innerText = |
| 1851 | + getBtns().children[0].querySelector('.button-renderer-text').innerText = |
1868 | 1852 | likesCount |
1869 | 1853 | return |
1870 | 1854 | } |
|
1895 | 1879 | if (isMobile) { return } |
1896 | 1880 | let rateBar = document.getElementById('return-youtube-dislike-bar-container') |
1897 | 1881 | const widthPx = |
1898 | | - getButtons().children[0].clientWidth + |
1899 | | - getButtons().children[1].clientWidth + |
| 1882 | + getBtns().children[0].clientWidth + |
| 1883 | + getBtns().children[1].clientWidth + |
1900 | 1884 | 8 |
1901 | 1885 | const widthPercent = likes + dislikes > 0 ? (likes / (likes + dislikes)) * 100 : 50 |
1902 | 1886 | let likePercentage = parseFloat(widthPercent.toFixed(1)) |
|
2157 | 2141 | function setEventListeners() { |
2158 | 2142 | let jsInitChecktimer |
2159 | 2143 | function checkForJS_Finish() { |
2160 | | - if (isShorts() || (getButtons()?.offsetParent && isVideoLoaded())) { |
2161 | | - const buttons = getButtons() |
| 2144 | + if (isShorts() || (getBtns()?.offsetParent && isVideoLoaded())) { |
| 2145 | + const buttons = getBtns() |
2162 | 2146 | if (!unsafeWindow.returnDislikeButtonlistenersSet) { |
2163 | 2147 | cLog('Registering button listeners...') |
2164 | 2148 | try { |
|
0 commit comments