Skip to content

Commit 2771eff

Browse files
committed
Improved getLikeCountFromButton()
± Replaced `false` returns w/ `null` - Deleted braces ± Replaced `let` w/ `const` ± Edited whitespace ↞ [auto-sync from https://github.com/adamlui/youtube-classic]
1 parent efa51fc commit 2771eff

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

youtube-classic/youtube-classic.user.js

Lines changed: 7 additions & 7 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.8
3+
// @version 2026.1.17.9
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
@@ -1889,13 +1889,13 @@
18891889

18901890
function getLikeCountFromButton() {
18911891
try {
1892-
if (isShorts()) { return false; }
1893-
let likeButton = getLikeButton().querySelector('yt-formatted-string#text') ??
1894-
getLikeButton().querySelector('button');
1895-
let likesStr = likeButton.getAttribute('aria-label').replace(/\D/g, '');
1896-
return likesStr.length ? parseInt(likesStr) : false;
1892+
if (isShorts()) return null
1893+
const likeBtn = getLikeButton().querySelector('yt-formatted-string#text')
1894+
?? getLikeButton().querySelector('button')
1895+
const likesStr = likeBtn.getAttribute('aria-label').replace(/\D/g, '')
1896+
return likesStr.length ? parseInt(likesStr) : null
18971897
}
1898-
catch { return false; }
1898+
catch { return null }
18991899
}
19001900

19011901
function createRateBar(likes, dislikes) {

0 commit comments

Comments
 (0)