Skip to content

Commit 8c395b3

Browse files
committed
Merged lines, shortened function names ↞ [auto-sync from https://github.com/adamlui/youtube-classic]
1 parent 1c8fc80 commit 8c395b3

1 file changed

Lines changed: 29 additions & 27 deletions

File tree

youtube-classic/youtube-classic.user.js

Lines changed: 29 additions & 27 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.55
3+
// @version 2026.1.20
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
@@ -1168,8 +1168,7 @@
11681168
'd: path("M12.7,12l6.6,6.6l-0.7,0.7L12,12.7l-6.6,6.6l-0.7-0.7l6.6-6.6L4.6,5.4l0.7-0.7l6.6,6.6l6.6-6.6l0.7,0.7L12.7,12z")',
11691169
'}'
11701170
].join('\n')
1171-
const btnStyle = document.createElement('style')
1172-
btnStyle.textContent = css
1171+
const btnStyle = document.createElement('style') ; btnStyle.textContent = css
11731172
const heads = document.getElementsByTagName('head'),
11741173
btnStyleParent = heads.length ? heads[0] : document.documentElement
11751174
btnStyleParent.append(btnStyle)
@@ -1321,11 +1320,13 @@
13211320

13221321
function createRateBar(likes, dislikes) {
13231322
if (isMobile) return
1324-
const rateBar = document.getElementById('return-youtube-dislike-bar-container')
1325-
const widthPx = getBtns().children[0].clientWidth + getBtns().children[1].clientWidth +8
1326-
const widthPercent = likes + dislikes > 0 ? (likes / (likes + dislikes)) *100 : 50
1327-
const likePercent = parseFloat(widthPercent.toFixed(1)).toLocaleString()
1328-
const dislikePercent = (100 - likePercent).toLocaleString()
1323+
1324+
const rateBar = document.getElementById('return-youtube-dislike-bar-container'),
1325+
widthPx = getBtns().children[0].clientWidth + getBtns().children[1].clientWidth +8,
1326+
widthPercent = likes + dislikes > 0 ? (likes / (likes + dislikes)) *100 : 50,
1327+
likePercent = parseFloat(widthPercent.toFixed(1)).toLocaleString(),
1328+
dislikePercent = (100 - likePercent).toLocaleString()
1329+
13291330
const tooltipInnerHTML = {
13301331
dash_like: `${likes.toLocaleString()} / ${
13311332
dislikes.toLocaleString()}  -  ${likePercent}%`,
@@ -1335,6 +1336,7 @@
13351336
only_like: `${likePercent}%`,
13361337
only_dislike: `${dislikePercent}%`
13371338
}[extConfig.tooltipPercentageMode] || `${likes.toLocaleString()} / ${dislikes.toLocaleString()}`
1339+
13381340
if (!rateBar && !isMobile) {
13391341
const colorDislikeStyle = extConfig.coloredBar ? `; background-color: ${getColorFromTheme(false)}` : ''
13401342
document.getElementById('menu-container').insertAdjacentHTML('beforeend', `
@@ -1352,6 +1354,7 @@
13521354
</tp-yt-paper-tooltip>
13531355
</div>
13541356
`)
1357+
13551358
} else {
13561359
const rydBar = document.getElementById('return-youtube-dislike-bar'),
13571360
rydBarContainer = document.getElementById('return-youtube-dislike-bar-container'),
@@ -1368,16 +1371,16 @@
13681371
function setState() {
13691372
cLog('Fetching votes...')
13701373
let statsSet = false
1371-
fetch(`https://returnyoutubedislikeapi.com/votes?videoId=${getVideoID()}`).then(resp =>
1374+
fetch(`https://returnyoutubedislikeapi.com/votes?videoId=${getVidID()}`).then(resp =>
13721375
resp.json().then(json => {
13731376
if (json && !('traceId' in resp) && !statsSet) {
13741377
const { dislikes, likes } = json
13751378
cLog(`Received count: ${dislikes}`)
13761379
likesVal = likes ; dislikesVal = dislikes
1377-
setDislikes(numberFormat(dislikes))
1380+
setDislikes(numFormat(dislikes))
13781381
if (extConfig.numberDisplayReformatLikes) {
13791382
const nativeLikes = getLikeCntFromBtn()
1380-
if (nativeLikes != null) setLikes(numberFormat(nativeLikes))
1383+
if (nativeLikes != null) setLikes(numFormat(nativeLikes))
13811384
}
13821385
createRateBar(likes, dislikes)
13831386
if (extConfig.coloredThumbs) {
@@ -1406,12 +1409,12 @@
14061409
if (prevState == 1) {
14071410
likesVal--
14081411
createRateBar(likesVal, dislikesVal)
1409-
setDislikes(numberFormat(dislikesVal))
1412+
setDislikes(numFormat(dislikesVal))
14101413
prevState = 3
14111414
} else if (prevState == 2) {
14121415
likesVal++
14131416
dislikesVal--
1414-
setDislikes(numberFormat(dislikesVal))
1417+
setDislikes(numFormat(dislikesVal))
14151418
createRateBar(likesVal, dislikesVal)
14161419
prevState = 1
14171420
} else if (prevState == 3) {
@@ -1421,7 +1424,7 @@
14211424
}
14221425
if (extConfig.numberDisplayReformatLikes) {
14231426
const nativeLikes = getLikeCntFromBtn()
1424-
if (nativeLikes != null) setLikes(numberFormat(nativeLikes))
1427+
if (nativeLikes != null) setLikes(numFormat(nativeLikes))
14251428
}
14261429
}
14271430
}
@@ -1430,38 +1433,37 @@
14301433
if (checkForUserAvatarButton()) {
14311434
if (prevState == 3) {
14321435
dislikesVal++
1433-
setDislikes(numberFormat(dislikesVal))
1436+
setDislikes(numFormat(dislikesVal))
14341437
createRateBar(likesVal, dislikesVal)
14351438
prevState = 2
14361439
} else if (prevState == 2) {
14371440
dislikesVal--
1438-
setDislikes(numberFormat(dislikesVal))
1441+
setDislikes(numFormat(dislikesVal))
14391442
createRateBar(likesVal, dislikesVal)
14401443
prevState = 3
14411444
} else if (prevState == 1) {
1442-
likesVal--
1443-
dislikesVal++
1444-
setDislikes(numberFormat(dislikesVal))
1445+
likesVal-- ; dislikesVal++
1446+
setDislikes(numFormat(dislikesVal))
14451447
createRateBar(likesVal, dislikesVal)
14461448
prevState = 2
14471449
if (extConfig.numberDisplayReformatLikes) {
14481450
const nativeLikes = getLikeCntFromBtn()
1449-
if (nativeLikes != null) setLikes(numberFormat(nativeLikes))
1451+
if (nativeLikes != null) setLikes(numFormat(nativeLikes))
14501452
}
14511453
}
14521454
}
14531455
}
14541456

1455-
function getVideoID() {
1457+
function getVidID() {
14561458
const urlObj = new URL(unsafeWindow.location.href), pathname = urlObj.pathname
14571459
return pathname.startsWith('/clip') ? document.querySelector('meta[itemprop="videoId"]')?.content
14581460
: pathname.startsWith('/shorts') ? pathname.slice(8)
14591461
: urlObj.searchParams.get('v')
14601462
}
14611463

1462-
function isVideoLoaded() {
1464+
function isVidLoaded() {
14631465
return isMobile ? document.getElementById('player').getAttribute('loading') == 'false'
1464-
: !!document.querySelector(`ytd-watch-flexy[video-id='${getVideoID()}']`)
1466+
: !!document.querySelector(`ytd-watch-flexy[video-id='${getVidID()}']`)
14651467
}
14661468

14671469
function roundDown(num) {
@@ -1472,12 +1474,12 @@
14721474
return val *10 ** decimal
14731475
}
14741476

1475-
function numberFormat(numState) {
1477+
function numFormat(numState) {
14761478
const numDisplay = !extConfig.numberDisplayRoundDown ? numState : roundDown(numState)
1477-
return getNumberFormatter(extConfig.numberDisplayFormat).format(numDisplay)
1479+
return getNumFormatter(extConfig.numberDisplayFormat).format(numDisplay)
14781480
}
14791481

1480-
function getNumberFormatter(optionSelect) {
1482+
function getNumFormatter(optionSelect) {
14811483
let userLocales
14821484
if (document.documentElement.lang) userLocales = document.documentElement.lang
14831485
else if (navigator.language) userLocales = navigator.language
@@ -1528,7 +1530,7 @@
15281530
function setEventListeners() {
15291531
let jsInitChecktimer
15301532
function checkForJS_Finish() {
1531-
if (isShorts() || (getBtns()?.offsetParent && isVideoLoaded())) {
1533+
if (isShorts() || (getBtns()?.offsetParent && isVidLoaded())) {
15321534
const buttons = getBtns()
15331535
if (!unsafeWindow.returnDislikeButtonlistenersSet) {
15341536
cLog('Registering button listeners...')

0 commit comments

Comments
 (0)