ajayyy / SponsorBlock

Skip YouTube video sponsors (browser extension)
https://sponsor.ajay.app
GNU General Public License v3.0
9.25k stars 299 forks source link

Fix refreshing #2036

Closed mini-bomba closed 2 weeks ago

mini-bomba commented 2 weeks ago

To test this pull request, follow the instructions in the wiki.


This PR fixes an issue that was reported on discord, where the after pressing the refresh button segments would sometimes show up and sometimes the segment list would be empty. Latest report/investigation thread in #concerns on discord

This appears to be caused by a hidden iframe which holds the page https://accounts.youtube.com/RotateCookiesPage, where the content script would be injected in addition to the root page. This iframe is only present when logged in, and as such this issue does not appear when logged out. Both the root and iframe content scripts would subscribe to messages from the popup page, which caused a sort of race condition when the refresh button was pressed. The iframe page's videoID would always be null. Due to a possible oversight, the sponsorsLookup function did not check whether videoID was valid, and ended up always trying to fetch the 7423 hashblock, which corresponds to the string null. Depending on which content script got the data first, the segments list in the popup would appear or disappear.

This PR mitigates this issue by:

ajayyy commented 2 weeks ago

nice