@@ -62,21 +62,22 @@ function addObserver() {
6262 const video = document . querySelector ( 'video' ) ;
6363 const observer = new MutationObserver ( ( mutations ) => {
6464 mutations . forEach ( ( mutation ) => {
65- if ( mutation . attributeName === 'src' ||
66- ( mutation . attributeName === 'loop' && video . getAttribute ( 'loop' ) === null && rotated === true ) ) {
67- rotated = false ;
68- updateToggleControls ( COLOR_OFF , TITLE_OFF , DEGREE_OFF ) ;
69- document . querySelector ( '[role=menuitemcheckbox]' ) . setAttribute ( 'aria-checked' , rotated ) ;
70- } else if ( mutation . attributeName === 'loop' && video . getAttribute ( 'loop' ) !== null && rotated === false ) {
71- rotated = true ;
72- updateToggleControls ( COLOR_ON , TITLE_ON , DEGREE_ON ) ;
73- document . querySelector ( '[role=menuitemcheckbox]' ) . setAttribute ( 'aria-checked' , rotated ) ;
65+ if ( mutation . attributeName === 'loop' ) {
66+ if ( video . getAttribute ( 'loop' ) === null && rotated ) {
67+ rotated = false ;
68+ updateToggleControls ( COLOR_OFF , TITLE_OFF , DEGREE_OFF ) ;
69+ }
70+ else if ( video . getAttribute ( 'loop' ) !== null && ! rotated ) {
71+ rotated = true ;
72+ updateToggleControls ( COLOR_ON , TITLE_ON , DEGREE_ON ) ;
73+ }
7474 }
7575 } ) ;
7676 } ) ;
7777 observer . observe ( video , { attributes : true } ) ;
7878}
7979
80+ // Add control over the YouTube context menu
8081function addContextMenuListener ( ) {
8182 const video = document . querySelector ( 'video' ) ;
8283 video . addEventListener ( 'contextmenu' , ( ) => {
0 commit comments