Skip to content

Commit ae9be46

Browse files
committed
Added dynamic pad actions div logic (fixes adamlui/youtube-classic#128) ↞ [auto-sync from https://github.com/adamlui/youtube-classic]
1 parent e6037a9 commit ae9be46

1 file changed

Lines changed: 21 additions & 2 deletions

File tree

youtube-classic/youtube-classic.user.js

Lines changed: 21 additions & 2 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.27
3+
// @version 2026.1.27.2
44
// @author Adam Lui, Magma_Craft, 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
@@ -1030,7 +1030,7 @@
10301030
yt-chip-cloud-chip-renderer:has(path[d^="M5 0a5 5"]) { display: none }
10311031
10321032
@media only screen and (min-width: 768px) { /* align sub btn right */
1033-
div#subscribe-button { position: absolute ; right: 0 } div#actions { padding-right: 125px }}
1033+
div#subscribe-button { position: absolute ; right: 0 }}
10341034
`)}
10351035
dom.get.loadedElem('head').then(() => document.head.append(app.styles.fixes))
10361036

@@ -1072,6 +1072,25 @@
10721072
})
10731073
dom.get.loadedElem('html').then(() => homeObserver.observe(document.documentElement, obsConfig))
10741074

1075+
// Set actions div padding + update when needed
1076+
dom.get.loadedElem('ytd-subscribe-button-renderer button').then(subBtn => {
1077+
setTimeout(updateActionsDivPadding, 5000)
1078+
new MutationObserver(updateActionsDivPadding).observe(subBtn, { childList: true, subtree: true })
1079+
window.addEventListener('resize', updateActionsDivPadding)
1080+
})
1081+
function updateActionsDivPadding() {
1082+
if (updateActionsDivPadding.timeout) clearTimeout(updateActionsDivPadding.timeout)
1083+
updateActionsDivPadding.timeout = setTimeout(async () => {
1084+
const actionsDiv = await dom.get.loadedElem('div#actions'),
1085+
bellIcon = await dom.get.loadedElem('[animated-icon-type=NOTIFICATION_BELL] svg'),
1086+
bellWidth = getComputedStyle(bellIcon).width,
1087+
idealActionsRpadding = !window.matchMedia('(min-width: 768px)').matches ? ''
1088+
: `${125 + (bellWidth.endsWith('px') ? parseInt(bellWidth.slice(0, -2)) : 0)}px`
1089+
if (getComputedStyle(actionsDiv).paddingRight != idealActionsRpadding)
1090+
actionsDiv.style.paddingRight = idealActionsRpadding
1091+
}, 50)
1092+
}
1093+
10751094
// Block stuff
10761095
document.head.append(app.styles.config ??= dom.create.style())
10771096
app.styles.config.textContent = Object.entries(app.selectors.site).map(([key, selectors]) =>

0 commit comments

Comments
 (0)