Skip to content

Commit a19b620

Browse files
committed
fix video controls not changing color automatically when theme changed in settings
1 parent bd02e02 commit a19b620

File tree

2 files changed

+28
-18
lines changed

2 files changed

+28
-18
lines changed

src/content-script/update-description-tab.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
371371
});
372372

373373
// Self-initialization function that runs when the content script loads
374-
function initializeContentScript() {
374+
function initializeDescriptionTab() {
375375
// Wait for the DOM to be fully loaded
376376
if (document.readyState === 'loading') {
377377
document.addEventListener('DOMContentLoaded', onDOMReady);
@@ -416,5 +416,5 @@ function initializeContentScript() {
416416
}
417417

418418
// Initialize the content script
419-
initializeContentScript();
419+
initializeDescriptionTab();
420420

src/content-script/update-solutions-tab.ts

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,18 @@ function updateAllElements(isDark: boolean) {
574574
button.style.borderColor = isDark ? 'rgba(255, 255, 255, 0.1)' : 'rgba(0, 0, 0, 0.1)';
575575
});
576576
});
577+
} else if (element.classList.contains('video-container')) {
578+
// Update only the controls container and channel element colors
579+
const controls = element.querySelector('div') as HTMLElement;
580+
if (controls) {
581+
controls.style.backgroundColor = isDark ? '#373737' : '#f3f4f5';
582+
controls.style.color = isDark ? '#fff' : '#1a1a1a';
583+
controls.style.border = `1px solid ${isDark ? 'rgba(255, 255, 255, 0.1)' : 'rgba(0, 0, 0, 0.1)'}`;
584+
}
585+
const channelElement = element.querySelector('#channel') as HTMLElement;
586+
if (channelElement) {
587+
channelElement.style.color = isDark ? '#fff' : '#1a1a1a';
588+
}
577589
} else {
578590
updateThemeForElement(element, isDark);
579591
}
@@ -695,7 +707,7 @@ function insertContent(searchBar: Element, title: string, result: any) {
695707
}
696708

697709
// Self-initialization function that runs when the content script loads
698-
function initializeContentScript() {
710+
function initializeSolutionsTab() {
699711
// Wait for the DOM to be fully loaded
700712
if (document.readyState === 'loading') {
701713
document.addEventListener('DOMContentLoaded', onDOMReady);
@@ -704,25 +716,23 @@ function initializeContentScript() {
704716
}
705717

706718
function onDOMReady() {
707-
// Check if we're on a LeetCode problem's solutions page
708-
const isSolutionsPage = /^https:\/\/leetcode\.com\/problems\/.*\/solutions\/?/.test(window.location.href);
719+
// Get the problem title from the page
720+
const problemTitle = document.title.replace(' - LeetCode', '');
709721

710-
if (isSolutionsPage) {
711-
console.log('LeetCode solutions page detected, initializing content script...');
712-
713-
// Extract the problem title from the page title
714-
const pageTitle = document.title;
715-
716-
// Update the solutions tab
717-
updateSolutionsTab(pageTitle);
718-
719-
console.log('Solutions tab content script initialized for problem:', pageTitle);
720-
}
722+
// Find the search bar to insert our content before it
723+
const searchBar = document.querySelector('div[class*="search"]');
724+
if (!searchBar) return;
725+
726+
// Load problem data and insert content
727+
chrome.storage.local.get(['leetcodeProblems'], (result) => {
728+
if (!result.leetcodeProblems) return;
729+
insertContent(searchBar, problemTitle, result);
730+
});
721731
}
722732
}
723733

724-
// Run the initialization
725-
initializeContentScript();
734+
// Initialize the content script
735+
initializeSolutionsTab();
726736

727737
chrome.runtime.onMessage.addListener((request) => {
728738
if (request.action === 'updateSolutions') {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy