Skip to content

Commit

Permalink
shortcuts.js:dark theme:no cookie editing for now
Browse files Browse the repository at this point in the history
  • Loading branch information
ImprovedTube authored May 6, 2024
1 parent f92b508 commit ac807b8
Showing 1 changed file with 3 additions and 23 deletions.
26 changes: 3 additions & 23 deletions js&css/web-accessible/www.youtube.com/shortcuts.js
Original file line number Diff line number Diff line change
Expand Up @@ -622,17 +622,15 @@ ImprovedTube.shortcutSubscribe = function () {
4.7.25 DARK THEME
------------------------------------------------------------------------------*/
ImprovedTube.shortcutDarkTheme = function () {
let darkCookie;
if (document.documentElement.hasAttribute('dark')) {
cookieValue = '80000';
document.documentElement.removeAttribute('dark');
document.querySelector('ytd-masthead').removeAttribute('dark');
document.getElementById("cinematics").style.visibility = 'hidden';
document.querySelector('ytd-masthead').style.backgroundColor ='#fff';
ImprovedTube.myColors(); ImprovedTube.setTheme();

} else { darkCookie = true;
document.documentElement.setAttribute('dark', '');
} else {
document.documentElement.setAttribute('dark', '');
if (this.storage.theme === 'custom' ){ this.elements.my_colors.remove(); }
if (this.storage.theme === 'dawn' ){ this.elements.dawn.remove(); }
if (document.documentElement.hasAttribute('it-themes') !== null && document.documentElement.hasAttribute('it-themes') === true){
Expand All @@ -641,26 +639,8 @@ let darkCookie;
}
document.querySelector('ytd-masthead').style.cssText = 'background-color: #000;';
document.getElementById("cinematics").style.visibility = 'visible';

}
let cookie = this.getPrefCookieValueByName('f6');
// f6 stores more than Theme. Treat it like hex number, we are only allowed to add/remove 0x80000 (light theme) and 0x400 (dark theme).
if (cookie && !isNaN(cookie)) {
// valid f6
let negation = parseInt(cookie, 16) & parseInt(80400, 16);
cookie = (parseInt(cookie, 16) - negation); // remove 80000 and 400
cookie = cookie ^ (darkCookie ? parseInt(400, 16) : 0); // apply optional darkCookie
cookie = cookie ? cookie.toString(16) : null; // back to hex, 0 means we want null to remove f6 cookie instead
} else {
// missing or corrupted f6, fully overwrite
cookie = darkCookie ? 400 : null;
}

this.setPrefCookieValueByName('f6', cookie);


}
};

/*------------------------------------------------------------------------------
4.7.26 CUSTOM MINI PLAYER
------------------------------------------------------------------------------*/
Expand Down

0 comments on commit ac807b8

Please sign in to comment.