Skip to content

Commit

Permalink
Update core.js initialize theme in case YT is in Dark cookie mode
Browse files Browse the repository at this point in the history
  • Loading branch information
raszpl authored May 8, 2024
1 parent 8acc734 commit 9f4bfa0
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions js&css/extension/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -303,16 +303,19 @@ extension.storage.listener = function () {

extension.storage.load = function (callback) {
chrome.storage.local.get(function (items) {
for (var key in items) {
var value = items[key];
extension.storage.data = items;

extension.storage.data[key] = value;
// initialize theme in case YT is in Dark cookie mode
if (!extension.storage.data['theme'] && document.documentElement.hasAttribute('dark')) {
extension.storage.data['theme'] = 'dark';
chrome.storage.local.set({theme: 'dark'});
}

document.documentElement.setAttribute('it-' + key.replace(/_/g, '-'), value);
for (const key in items) {
document.documentElement.setAttribute('it-' + key.replace(/_/g, '-'), items[key]);
}

extension.events.trigger('storage-loaded');

extension.messages.send({
action: 'storage-loaded',
storage: items
Expand All @@ -322,4 +325,4 @@ extension.storage.load = function (callback) {
callback(extension.storage.data);
}
});
};
};

0 comments on commit 9f4bfa0

Please sign in to comment.