Skip to content

Commit 76da54c

Browse files
committed
Re-cased ID func/var names, condensed getVideoId() + isVIdeoLoaded() ↞ [auto-sync from https://github.com/adamlui/youtube-classic]
1 parent f21f92a commit 76da54c

1 file changed

Lines changed: 11 additions & 15 deletions

File tree

youtube-classic/youtube-classic.user.js

Lines changed: 11 additions & 15 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.46
3+
// @version 2026.1.17.47
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
@@ -204,8 +204,8 @@
204204
const thisQuadrantQueue = notifyProps.queue[notificationDiv.quadrant]
205205
if (thisQuadrantQueue.length > 1) {
206206
try { // to move old notifications
207-
for (const divId of thisQuadrantQueue.slice(0, -1)) { // exclude new div
208-
const oldDiv = document.getElementById(divId),
207+
for (const divID of thisQuadrantQueue.slice(0, -1)) { // exclude new div
208+
const oldDiv = document.getElementById(divID),
209209
offsetProp = oldDiv.style.top ? 'top' : 'bottom', // pick property to change
210210
vOffset = +parseInt(oldDiv.style[offsetProp]) +5 + oldDiv.getBoundingClientRect().height
211211
oldDiv.style[offsetProp] = `${vOffset}px` // change prop
@@ -1384,7 +1384,7 @@
13841384
cLog('Fetching votes...')
13851385
let statsSet = false
13861386
fetch(
1387-
`https://returnyoutubedislikeapi.com/votes?videoId=${getVideoId()}`
1387+
`https://returnyoutubedislikeapi.com/votes?videoId=${getVideoID()}`
13881388
).then((response) => {
13891389
response.json().then((json) => {
13901390
if (json && !('traceId' in response) && !statsSet) {
@@ -1472,20 +1472,16 @@
14721472

14731473
function setInitialState() { setState() }
14741474

1475-
function getVideoId() {
1476-
const urlObject = new URL(unsafeWindow.location.href)
1477-
const pathname = urlObject.pathname
1478-
if (pathname.startsWith('/clip')) { return document.querySelector('meta[itemprop="videoId"]').content
1479-
} else {
1480-
if (pathname.startsWith('/shorts')) { return pathname.slice(8) }
1481-
return urlObject.searchParams.get('v')
1482-
}
1475+
function getVideoID() {
1476+
const urlObj = new URL(unsafeWindow.location.href), pathname = urlObj.pathname
1477+
return pathname.startsWith('/clip') ? document.querySelector('meta[itemprop="videoId"]')?.content
1478+
: pathname.startsWith('/shorts') ? pathname.slice(8)
1479+
: urlObj.searchParams.get('v')
14831480
}
14841481

14851482
function isVideoLoaded() {
1486-
if (isMobile) { return document.getElementById('player').getAttribute('loading') == 'false' }
1487-
const videoId = getVideoId()
1488-
return ( document.querySelector(`ytd-watch-flexy[video-id='${videoId}']`) != null )
1483+
return isMobile ? document.getElementById('player').getAttribute('loading') == 'false'
1484+
: document.querySelector(`ytd-watch-flexy[video-id='${getVideoID()}']`)
14891485
}
14901486

14911487
function roundDown(num) {

0 commit comments

Comments
 (0)