Skip to content

Commit fb02477

Browse files
committed
Condensed getLikeBtn() ↞ [auto-sync from https://github.com/adamlui/youtube-classic]
1 parent 9757c63 commit fb02477

1 file changed

Lines changed: 11 additions & 13 deletions

File tree

youtube-classic/youtube-classic.user.js

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// ==UserScript==
22
// @name YouTube™ Classic 📺 — (Remove rounded design + Return YouTube dislikes)
3-
// @version 2026.1.17.22
3+
// @version 2026.1.17.23
44
// @author Adam Lui, Magma_Craft, Anarios, JRWR, Fuim & hoothin
55
// @namespace https://github.com/adamlui
66
// @description Reverts YouTube to its classic design (before all the rounded corners & hidden dislikes) + redirects YouTube Shorts
@@ -1775,18 +1775,16 @@
17751775
return document.getElementById('menu-container')?.querySelector('#top-level-buttons-computed')
17761776
}
17771777

1778-
function getLikeButton() {
1779-
return getBtns().children[0].tagName ==
1780-
'YTD-SEGMENTED-LIKE-DISLIKE-BUTTON-RENDERER'
1781-
? getBtns().children[0].children[0]
1782-
: getBtns().children[0]
1778+
function getLikeBtn() {
1779+
let firstBtn = getBtns().children[0]
1780+
return firstBtn.tagName == 'YTD-SEGMENTED-LIKE-DISLIKE-BUTTON-RENDERER' ? firstBtn.children[0] : firstBtn
17831781
}
17841782

17851783
function getLikeTextContainer() {
17861784
return (
1787-
getLikeButton().querySelector('#text') ??
1788-
getLikeButton().getElementsByTagName('yt-formatted-string')[0] ??
1789-
getLikeButton().querySelector('span[role="text"]')
1785+
getLikeBtn().querySelector('#text') ??
1786+
getLikeBtn().getElementsByTagName('yt-formatted-string')[0] ??
1787+
getLikeBtn().querySelector('span[role="text"]')
17901788
)
17911789
}
17921790

@@ -1867,8 +1865,8 @@
18671865
function getLikeCountFromButton() {
18681866
try {
18691867
if (isShorts()) return null
1870-
const likeBtn = getLikeButton().querySelector('yt-formatted-string#text')
1871-
?? getLikeButton().querySelector('button')
1868+
const likeBtn = getLikeBtn().querySelector('yt-formatted-string#text')
1869+
?? getLikeBtn().querySelector('button')
18721870
const likesStr = likeBtn.getAttribute('aria-label').replace(/\D/g, '')
18731871
return likesStr.length ? parseInt(likesStr) : null
18741872
}
@@ -1971,7 +1969,7 @@
19711969
if (extConfig.coloredThumbs) {
19721970
if (isShorts()) {
19731971
// for shorts, leave deactived buttons in default color
1974-
let shortLikeButton = getLikeButton().querySelector(
1972+
let shortLikeButton = getLikeBtn().querySelector(
19751973
'tp-yt-paper-button#button'
19761974
)
19771975
let shortDislikeButton = getDislikeButton().querySelector(
@@ -1992,7 +1990,7 @@
19921990
mutationObserver.options
19931991
)
19941992
} else {
1995-
getLikeButton().style.color = getColorFromTheme(true)
1993+
getLikeBtn().style.color = getColorFromTheme(true)
19961994
getDislikeButton().style.color = getColorFromTheme(false)
19971995
}
19981996
}

0 commit comments

Comments
 (0)