WofWca / jumpcutter

⏩ Fast-forwards long pauses between sentences — watch lectures ~1.5x faster (browser extension)
https://chrome.google.com/webstore/detail/jump-cutter/lmppdpldfpfdlipofacekcfleacbbncp
GNU Affero General Public License v3.0
356 stars 13 forks source link

improvement: don't clone MediaSources when not needed #175

Closed WofWca closed 4 months ago

WofWca commented 4 months ago

i.e. when the experimental algorithm or the whole extension is disabled

This has 3 benefits:

However, this change has side-effects: now, after enabling the experimental algorithm on websites that rely on MediaSource cloning, the page needs to be reloaded, but there is no clear indication of it now.

The motivation for this is to finally release the version that includes the new MediaSource cloning algorithm (https://github.com/WofWca/jumpcutter/commit/e9daff122f12263a50fb1c4a10e4b13c7fd190cf) to Chromium (where the majority of users are) in a safer way, so that it can be disabled and can't break websites, e.g. by overriding canConstructInDedicatedWorker (see src/entry-points/content/cloneMediaSources/lib.ts#L460).

Although, based on my testing, the algorithm appears to be quite stable, especially with the recent fixes, at least on YouTube.

About the changes to manifest.json: The new host_permissions won't trigger a permission warning upon update, at least on Chromium. I tested this, using this guide: https://developer.chrome.com/docs/extensions/develop/concepts/permission-warnings#view_warnings Did not test on Gecko (Firefox). This, I suspect, is because the "Read and change all your data on all websites." permission is already granted thanks to content_scripts.matches https://developer.chrome.com/docs/extensions/reference/permissions-list

The "scripting" permission doesn't trigger a warning at all

The docs say that for scripting.registerContentScripts() to work we need either "host_permissions" or the "activeTab" permission. "activeTab" is not enough, because this way the script is only injected on pages on which the user has interacted with the extension, e.g. opened the popup, which means they would need to do this before the original MediaSource is created, or reload the page.

Co-authored-by: WofWca Commit message by WofWca