Skip to content

Commit 87224b9

Browse files
committed
Condensed/renamed mutationObserver ↞ [auto-sync from https://github.com/adamlui/youtube-classic]
1 parent e676011 commit 87224b9

1 file changed

Lines changed: 20 additions & 28 deletions

File tree

youtube-classic/youtube-classic.user.js

Lines changed: 20 additions & 28 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.54
3+
// @version 2026.1.17.55
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
@@ -1272,32 +1272,24 @@
12721272
return result
12731273
}
12741274

1275-
const mutationObserver = new Object()
1276-
1277-
if (isShorts() && !mutationObserver.exists) {
1275+
const shortsObs = new Object()
1276+
if (isShorts() && !shortsObs.exists) {
12781277
cLog('initializing mutation observer')
1279-
mutationObserver.options = { childList: false, attributes: true, subtree: false }
1280-
mutationObserver.exists = true
1281-
mutationObserver.observer = new MutationObserver(function(mutationList) {
1282-
mutationList.forEach(mutation => {
1283-
if (
1284-
mutation.type == 'attributes' &&
1285-
mutation.target.nodeName == 'TP-YT-PAPER-BUTTON' &&
1286-
mutation.target.id == 'button'
1287-
) {
1288-
cLog('Short thumb button status changed')
1289-
if (mutation.target.getAttribute('aria-pressed') == 'true') {
1290-
mutation.target.style.color =
1291-
mutation.target.parentElement.parentElement.id == 'like-button'
1292-
? getColorFromTheme(true)
1293-
: getColorFromTheme(false)
1294-
} else {
1295-
mutation.target.style.color = 'unset'
1296-
}
1297-
return
1298-
}
1299-
cLog(`unexpected mutation observer event: ${mutation.target.nodeName} ${mutation.type}`)
1300-
})})
1278+
shortsObs.options = { childList: false, attributes: true, subtree: false }
1279+
shortsObs.exists = true
1280+
shortsObs.observer = new MutationObserver(mutations => mutations.forEach(mutation => {
1281+
if (mutation.type == 'attributes'
1282+
&& mutation.target.nodeName == 'TP-YT-PAPER-BUTTON'
1283+
&& mutation.target.id == 'button'
1284+
) {
1285+
cLog('Short thumb button status changed')
1286+
return mutation.target.style.color =
1287+
mutation.target.getAttribute('aria-pressed') == 'true' ?
1288+
getColorFromTheme(mutation.target.parentElement.parentElement.id == 'like-button')
1289+
: 'unset'
1290+
}
1291+
cLog(`unexpected mutation observer event: ${mutation.target.nodeName} ${mutation.type}`)
1292+
}))
13011293
}
13021294

13031295
function checkForUserAvatarButton() {
@@ -1397,8 +1389,8 @@
13971389
shortLikeBtn.style.color = getColorFromTheme(true)
13981390
if (shortDislikeBtn.getAttribute('aria-pressed') == 'true')
13991391
shortDislikeBtn.style.color = getColorFromTheme(false)
1400-
mutationObserver.observer.observe(shortLikeBtn, mutationObserver.options)
1401-
mutationObserver.observer.observe(shortDislikeBtn, mutationObserver.options)
1392+
shortsObs.observer.observe(shortLikeBtn, shortsObs.options)
1393+
shortsObs.observer.observe(shortDislikeBtn, shortsObs.options)
14021394
} else {
14031395
getLikeBtn().style.color = getColorFromTheme(true)
14041396
getDislikeBtn().style.color = getColorFromTheme(false)

0 commit comments

Comments
 (0)