Skip to content

Commit 7964a13

Browse files
committed
Eliminated unneeded booelan literals + symbols, replaced if/else w/ ternary, shortened var names ↞ [auto-sync from https://github.com/adamlui/youtube-classic]
1 parent b6f2696 commit 7964a13

1 file changed

Lines changed: 14 additions & 20 deletions

File tree

youtube-classic/youtube-classic.user.js

Lines changed: 14 additions & 20 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.19
3+
// @version 2026.1.17.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
@@ -1831,16 +1831,12 @@
18311831

18321832
let mutationObserver = new Object()
18331833

1834-
if (isShorts() && mutationObserver.exists != true) {
1834+
if (isShorts() && !mutationObserver.exists) {
18351835
cLog('initializing mutation observer')
1836-
mutationObserver.options = {
1837-
childList: false,
1838-
attributes: true,
1839-
subtree: false
1840-
}
1836+
mutationObserver.options = { childList: false, attributes: true, subtree: false }
18411837
mutationObserver.exists = true
18421838
mutationObserver.observer = new MutationObserver(function(mutationList) {
1843-
mutationList.forEach((mutation) => {
1839+
mutationList.forEach(mutation => {
18441840
if (
18451841
mutation.type == 'attributes' &&
18461842
mutation.target.nodeName == 'TP-YT-PAPER-BUTTON' &&
@@ -1983,12 +1979,12 @@
19831979
likesvalue = likes
19841980
dislikesvalue = dislikes
19851981
setDislikes(numberFormat(dislikes))
1986-
if (extConfig.numberDisplayReformatLikes == true) {
1982+
if (extConfig.numberDisplayReformatLikes) {
19871983
const nativeLikes = getLikeCountFromButton()
19881984
if (nativeLikes != null) setLikes(numberFormat(nativeLikes))
19891985
}
19901986
createRateBar(likes, dislikes)
1991-
if (extConfig.coloredThumbs == true) {
1987+
if (extConfig.coloredThumbs) {
19921988
if (isShorts()) {
19931989
// for shorts, leave deactived buttons in default color
19941990
let shortLikeButton = getLikeButton().querySelector(
@@ -2039,7 +2035,7 @@
20392035
createRateBar(likesvalue, dislikesvalue)
20402036
previousState = 1
20412037
}
2042-
if (extConfig.numberDisplayReformatLikes == true) {
2038+
if (extConfig.numberDisplayReformatLikes) {
20432039
const nativeLikes = getLikeCountFromButton()
20442040
if (nativeLikes != null) setLikes(numberFormat(nativeLikes))
20452041
}
@@ -2064,7 +2060,7 @@
20642060
setDislikes(numberFormat(dislikesvalue))
20652061
createRateBar(likesvalue, dislikesvalue)
20662062
previousState = 2
2067-
if (extConfig.numberDisplayReformatLikes == true) {
2063+
if (extConfig.numberDisplayReformatLikes) {
20682064
const nativeLikes = getLikeCountFromButton()
20692065
if (nativeLikes != null) setLikes(numberFormat(nativeLikes))
20702066
}
@@ -2098,18 +2094,16 @@
20982094
return value * 10 ** decimal
20992095
}
21002096

2101-
function numberFormat(numberState) {
2102-
let numberDisplay
2103-
if (extConfig.numberDisplayRoundDown == false) { numberDisplay = numberState
2104-
} else { numberDisplay = roundDown(numberState) }
2105-
return getNumberFormatter(extConfig.numberDisplayFormat).format(numberDisplay)
2097+
function numberFormat(numState) {
2098+
const numDisplay = !extConfig.numberDisplayRoundDown ? numState : roundDown(numState)
2099+
return getNumberFormatter(extConfig.numberDisplayFormat).format(numDisplay)
21062100
}
21072101

21082102
function getNumberFormatter(optionSelect) {
21092103
let userLocales
2110-
if (document.documentElement.lang) { userLocales = document.documentElement.lang
2111-
} else if (navigator.language) { userLocales = navigator.language
2112-
} else {
2104+
if (document.documentElement.lang) userLocales = document.documentElement.lang
2105+
else if (navigator.language) userLocales = navigator.language
2106+
else {
21132107
try {
21142108
userLocales = new URL(
21152109
Array.from(document.querySelectorAll('head > link[rel="search"]'))

0 commit comments

Comments
 (0)