From b13c773b5656bc4ca78bc05ccc0348800fca61ea Mon Sep 17 00:00:00 2001 From: Rasz_pl Date: Tue, 30 Apr 2024 14:20:41 +0200 Subject: [PATCH] Update themes.js 'ytd-masthead') no guaranteed to exists, fixes random extension crash on load --- js&css/web-accessible/www.youtube.com/themes.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/js&css/web-accessible/www.youtube.com/themes.js b/js&css/web-accessible/www.youtube.com/themes.js index 5edcd49d3..b47884788 100644 --- a/js&css/web-accessible/www.youtube.com/themes.js +++ b/js&css/web-accessible/www.youtube.com/themes.js @@ -75,7 +75,9 @@ ImprovedTube.myColors = function () { document.getElementById("cinematics").style.visibility = 'hidden'; document.getElementById("cinematics").style.display = 'none !important'; } - document.querySelector('ytd-masthead').style.backgroundColor = ''+primary_color+''; + if (document.querySelector('ytd-masthead')) { + document.querySelector('ytd-masthead').style.backgroundColor = ''+primary_color+''; + } } else { //theoretically this will never be called this.elements.my_colors?.remove(); } @@ -94,7 +96,9 @@ let darkCookie; document.getElementById('cinematics').style.display = 'none !important'; } this.elements.my_colors?.remove(); - document.querySelector('ytd-masthead').style.backgroundColor ='#000'; + if (document.querySelector('ytd-masthead')) { + document.querySelector('ytd-masthead').style.backgroundColor ='#000'; + } break case 'default':