zubyj / leetcode-explained

Browser extension that adds video solutions, company tags, and GPT code analysis into Leetcode problems
https://leetcodeapp.com
MIT License
86 stars 13 forks source link

Video is not being injected when problem is navigated to. Only injected when refreshing the page. #9

Closed zubyj closed 1 year ago

zubyj commented 1 year ago

Fixed with commit 24c461ab9e4dd162f3583b97ac09038146935dcc

Updating the manifest with the new pattern "https://leetcode.com/problems/*" made the content script inject-solution-video.js run on all problem pages, including the problem statement and the solutions tab.

Previously, the content script was only running on the specific URL pattern "https://leetcode.com/problems/*/solutions/*", which meant that the script only executed when the URL matched that exact pattern. When navigating between the problem statement and solutions tab, the URL didn't change to match the pattern, so the content script wasn't running.

By changing the URL pattern to "https://leetcode.com/problems/*", the content script is now running on all problem pages. This means that when navigating between the problem statement and solutions tab, the content script is already running, and it can observe the DOM changes and inject the video when the solutions tab becomes visible.

This change resolved the issue because the content script is now active on the problem pages and can detect when the solutions tab is visible without relying on the URL change.