8
8
// @license AGPL-3.0-only
9
9
// @author Sv443
10
10
// @copyright Sv443 (https://github.com/Sv443)
11
- // @icon https://cdn.jsdelivr.net/gh/Sv443/BetterYTM@bc5f4bcc /assets/images/logo/logo_dev_48.png
11
+ // @icon https://cdn.jsdelivr.net/gh/Sv443/BetterYTM@1d2bc5a5 /assets/images/logo/logo_dev_48.png
12
12
// @match https://music.youtube.com/*
13
13
// @match https://www.youtube.com/*
14
14
// @run -at document-start
@@ -335,7 +335,7 @@ const rawConsts = {
335
335
mode : "development" ,
336
336
branch : "develop" ,
337
337
host : "github" ,
338
- buildNumber : "bc5f4bcc " ,
338
+ buildNumber : "1d2bc5a5 " ,
339
339
assetSource : "jsdelivr" ,
340
340
devServerPort : "8710" ,
341
341
} ;
@@ -1976,6 +1976,7 @@ async function getAutoLikeDialog() {
1976
1976
error ( "Couldn't refresh auto-like channels dialog:" , err ) ;
1977
1977
}
1978
1978
} ) ;
1979
+ autoLikeDialog . on ( "open" , ( ) => { var _a ; return ( _a = document . querySelector ( ".bytm-auto-like-channels-searchbar" ) ) === null || _a === void 0 ? void 0 : _a . focus ( ) ; } ) ;
1979
1980
autoLikeDialog . on ( "close" , ( ) => emitSiteEvent ( "autoLikeChannelsUpdated" ) ) ;
1980
1981
}
1981
1982
if ( ! autoLikeExImDialog ) {
@@ -2028,7 +2029,7 @@ async function renderBody$4() {
2028
2029
const contElem = document . createElement ( "div" ) ;
2029
2030
const descriptionEl = document . createElement ( "p" ) ;
2030
2031
descriptionEl . classList . add ( "bytm-auto-like-channels-desc" ) ;
2031
- descriptionEl . textContent = t ( "auto_like_channels_dialog_desc" ) ;
2032
+ descriptionEl . textContent = descriptionEl . ariaLabel = t ( "auto_like_channels_dialog_desc" ) ;
2032
2033
descriptionEl . tabIndex = 0 ;
2033
2034
contElem . appendChild ( descriptionEl ) ;
2034
2035
const searchCont = document . createElement ( "div" ) ;
@@ -2038,6 +2039,7 @@ async function renderBody$4() {
2038
2039
searchContLeftSideEl . classList . add ( "left-side" ) ;
2039
2040
searchCont . appendChild ( searchContLeftSideEl ) ;
2040
2041
const searchContRightSideEl = document . createElement ( "div" ) ;
2042
+ searchContRightSideEl . tabIndex = 0 ;
2041
2043
searchContRightSideEl . classList . add ( "right-side" ) ;
2042
2044
searchCont . appendChild ( searchContRightSideEl ) ;
2043
2045
const updateCountElem = ( ) => {
@@ -2048,7 +2050,7 @@ async function renderBody$4() {
2048
2050
updateCountElem ( ) ;
2049
2051
const searchbarEl = document . createElement ( "input" ) ;
2050
2052
searchbarEl . classList . add ( "bytm-auto-like-channels-searchbar" ) ;
2051
- searchbarEl . placeholder = t ( "search_placeholder" ) ;
2053
+ searchbarEl . placeholder = searchbarEl . ariaDescription = t ( "search_placeholder" ) ;
2052
2054
searchbarEl . type = searchbarEl . role = "search" ;
2053
2055
searchbarEl . tabIndex = 0 ;
2054
2056
searchbarEl . autofocus = true ;
@@ -5130,7 +5132,7 @@ async function initAboveQueueBtns() {
5130
5132
} ) ;
5131
5133
}
5132
5134
//#region thumb.overlay
5133
- // TODO:FIXME: re-grab video ID on thumbnail overlay toggle to ensure eventual consistency
5135
+ // TODO:FIXME: rewrite this whole chonker cause it doesn't wanna behave at all
5134
5136
/** Changed when the toggle button is pressed - used to invert the state of "showOverlay" */
5135
5137
let invertOverlay = false ;
5136
5138
/** List of video IDs that have already been applied to the thumbnail overlay */
@@ -5213,8 +5215,7 @@ async function initThumbnailOverlay() {
5213
5215
if ( thumbImgElem ) {
5214
5216
thumbImgElem . dataset . videoId = videoID ;
5215
5217
thumbImgElem . src = thumbUrl ;
5216
- // crop horizontal bezels on songs:
5217
- thumbImgElem . style . objectFit = getCurrentMediaType ( ) === "video" ? "contain" : "cover" ;
5218
+ thumbImgElem . dataset . mediaType = getCurrentMediaType ( ) ;
5218
5219
}
5219
5220
log ( "Applied thumbnail URL to overlay:" , thumbUrl ) ;
5220
5221
} ;
@@ -5521,19 +5522,19 @@ async function initWatchPageFullSize() {
5521
5522
else
5522
5523
log ( "Made watch page full size" ) ;
5523
5524
} //#region utils
5524
- const ignoreTagNamesInput = [ "INPUT" , "TEXTAREA" , "SELECT" , "BUTTON" , "A" ] ;
5525
- const ignoreIdsInput = [
5525
+ const ignoreInputTagNames = [ "INPUT" , "TEXTAREA" , "SELECT" , "BUTTON" , "A" ] ;
5526
+ const ignoreInputIds = [
5526
5527
"contenteditable-root" , // comment field on YT
5527
5528
"volume-slider" , // volume slider on YTM
5528
5529
] ;
5529
- const ignoreClassNamesInput = [ ] ;
5530
- /** Returns true, if the given element (document.activeElement by default) is an input element that should make BYTM ignore keypresses */
5530
+ const ignoreInputClassNames = [ ] ;
5531
+ /** Returns true, if the given element (` document.activeElement` by default) is an input element that should make BYTM ignore keypresses */
5531
5532
function isIgnoredInputElement ( el = document . activeElement ) {
5532
5533
if ( ! el )
5533
5534
return false ;
5534
- return ignoreTagNamesInput . includes ( el . tagName . toUpperCase ( ) )
5535
- || ignoreClassNamesInput . some ( ( cls ) => el . classList . contains ( cls ) )
5536
- || ignoreIdsInput . includes ( el . id ) ;
5535
+ return document . activeElement !== document . body && ( ignoreInputTagNames . includes ( el . tagName . toUpperCase ( ) )
5536
+ || ignoreInputClassNames . some ( ( cls ) => el . classList . contains ( cls ) )
5537
+ || ignoreInputIds . includes ( el . id ) ) ;
5537
5538
}
5538
5539
//#region arrow key skip
5539
5540
let sliderEl ;
@@ -5543,7 +5544,7 @@ async function initArrowKeySkip() {
5543
5544
} ) ;
5544
5545
document . addEventListener ( "keydown" , ( evt ) => {
5545
5546
var _a , _b ;
5546
- if ( ! getFeature ( "arrowKeySupport" ) )
5547
+ if ( ! getFeature ( "arrowKeySupport" ) || isIgnoredInputElement ( ) )
5547
5548
return ;
5548
5549
if ( [ "ArrowUp" , "ArrowDown" ] . includes ( evt . code ) && getDomain ( ) === "ytm" )
5549
5550
return handleVolumeKeyPress ( evt ) ;
@@ -5587,9 +5588,7 @@ function handleVolumeKeyPress(evt) {
5587
5588
/** Initializes the feature that lets users skip by a frame with the period and comma keys while the video is paused */
5588
5589
async function initFrameSkip ( ) {
5589
5590
document . addEventListener ( "keydown" , async ( evt ) => {
5590
- if ( ! getFeature ( "frameSkip" ) )
5591
- return ;
5592
- if ( ! [ "Comma" , "Period" ] . includes ( evt . code ) )
5591
+ if ( ! getFeature ( "frameSkip" ) || isIgnoredInputElement ( ) || ! [ "Comma" , "Period" ] . includes ( evt . code ) )
5593
5592
return ;
5594
5593
const vid = getVideoElement ( ) ;
5595
5594
if ( ! vid || vid . readyState === 0 )
@@ -5608,14 +5607,10 @@ async function initFrameSkip() {
5608
5607
/** Adds the ability to skip to a certain time in the video by pressing a number key (0-9) */
5609
5608
async function initNumKeysSkip ( ) {
5610
5609
document . addEventListener ( "keydown" , ( e ) => {
5611
- if ( ! getFeature ( "numKeysSkipToTime" ) )
5610
+ if ( ! getFeature ( "numKeysSkipToTime" ) || isIgnoredInputElement ( ) )
5612
5611
return ;
5613
5612
if ( ! e . key . trim ( ) . match ( / ^ [ 0 - 9 ] $ / ) )
5614
5613
return ;
5615
- // discard the event when an unexpected element is currently active or in focus, like when editing a playlist or when the search bar is focused
5616
- const ignoreElement = isIgnoredInputElement ( ) ;
5617
- if ( ( document . activeElement !== document . body && ignoreElement ) || ignoreElement )
5618
- return info ( "Captured valid key to skip video to, but ignored it since this element is currently active:" , document . activeElement ) ;
5619
5614
const vidElem = getVideoElement ( ) ;
5620
5615
if ( ! vidElem || vidElem . readyState === 0 )
5621
5616
return warn ( "Could not find video element, so the keypress is ignored" ) ;
0 commit comments