Skip to content

Commit

Permalink
Merge pull request #2325 from raszpl/patch-3
Browse files Browse the repository at this point in the history
Update themes.js cleanup
  • Loading branch information
ImprovedTube authored Jun 9, 2024
2 parents 4c785fe + 3cb56ae commit 6d369c1
Showing 1 changed file with 8 additions and 16 deletions.
24 changes: 8 additions & 16 deletions js&css/web-accessible/www.youtube.com/themes.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,49 +74,41 @@ ImprovedTube.myColors = function () {
document.documentElement.appendChild(style);
document.documentElement.removeAttribute('dark');
document.querySelector('ytd-masthead')?.removeAttribute('dark');
if(document.getElementById("cinematics") !== null)
{document.getElementById("cinematics").style.visibility = 'hidden';
document.getElementById("cinematics").style.display = 'none !important';}
document.getElementById('cinematics')?.style.setProperty("display", "none");
} else {
this.elements.my_colors?.remove();
}
}

ImprovedTube.setTheme = function () {

function showCinematics() { if(document.getElementById("cinematics") !== null)
{document.getElementById("cinematics").style.visibility = '';
document.getElementById("cinematics").style.display = '';}}

switch(this.storage.theme) {
case 'dark':
document.documentElement.setAttribute('dark', '');
if (document.querySelector('ytd-masthead')) { document.querySelector('ytd-masthead').setAttribute('dark', ''); }
document.querySelector('ytd-masthead')?.setAttribute('dark', '');
ImprovedTube.setPrefCookieValueByName('f6', 400);
showCinematics();
// fall through
case 'black':
document.getElementById('cinematics')?.removeAttribute('style');
this.elements.my_colors?.remove();
break

case 'light':
ImprovedTube.messages.send({action: 'set', key: 'theme', value: null});
ImprovedTube.setPrefCookieValueByName('f6', null);
if(document.getElementById("cinematics") !== null)
{document.getElementById("cinematics").style.visibility = 'hidden';
document.getElementById("cinematics").style.display = 'none !important';}
// fall through
case 'dawn':
case 'dawn':
case 'sunset':
case 'night':
case 'plain':
case 'desert':
document.documentElement.removeAttribute('dark');
document.querySelector('ytd-masthead')?.removeAttribute('dark');
document.getElementById('cinematics')?.removeAttribute('style');
document.getElementById('cinematics')?.style.setProperty('display', 'none');
this.elements.my_colors?.remove();
break

case 'default':
showCinematics();
document.getElementById('cinematics')?.removeAttribute('style');
this.elements.my_colors?.remove();
break
}
Expand Down

0 comments on commit 6d369c1

Please sign in to comment.