Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to Manifest V3 #18

Open
1 of 2 tasks
jprochazk opened this issue Sep 28, 2022 · 2 comments
Open
1 of 2 tasks

Update to Manifest V3 #18

jprochazk opened this issue Sep 28, 2022 · 2 comments
Assignees

Comments

@jprochazk
Copy link
Contributor

jprochazk commented Sep 28, 2022

Google is killing content blockers by removing webRequestBlocking API from extensions using Manifest v3, and removing support for Manifest v2. This affects Holodex+, because we use that API.

If either of these turn out to be blockers for using mv3, then we'll have to maintain separate versions for Chrome/Chromium and non-Chromium browsers (e.g. Firefox).


Notes

We use webRequestBlocking for:

  1. Stripping headers to allow embedding of archive chat

    webRequest.onHeadersReceived.addListener(
    (details) => {
    return {
    responseHeaders: details?.responseHeaders?.filter((header) => header.name.toLowerCase() !== "x-frame-options"),
    };
    },
    { urls: ["*://*.youtube.com/live_chat_replay?*"] },
    ["blocking", "responseHeaders"]
    );

  2. Redirecting a fake embed chat link to embed archive chat - this is dynamic, so may end up being a problem.

    webRequest.onHeadersReceived.addListener(
    (details) => {
    const q = new URL(details.url);
    const videoId = q.searchParams.get("v");
    const channelId = q.searchParams.get("c");
    const darkTheme = q.searchParams.get("dark_theme");
    const continuation =
    videoId &&
    channelId &&
    rrc({
    videoId,
    channelId,
    });
    const redirect = new URL("https://www.youtube.com/live_chat_replay");
    if(continuation) redirect.searchParams.set("continuation", continuation);
    if(darkTheme) redirect.searchParams.set("dark_theme", darkTheme);
    return {
    redirectUrl: redirect.toString(),
    };
    },
    { urls: ["https://www.youtube.com/redirect_replay_chat?*"] },
    ["blocking", "responseHeaders"]
    );

@jprochazk jprochazk self-assigned this Sep 28, 2022
@sphinxrave
Copy link
Contributor

For investigating the changes of going from background pages to serviceworker, perhaps it's not a huge deal? Content-Script still works like normal, it's just the background script that becomes more like service worker.

https://stackoverflow.com/questions/71369177/chrome-extension-onmessage-addlistener-vs-chrome-runtime-onmessage-addlistener-o

https://stackoverflow.com/questions/75824421/should-a-mv3-extension-use-chrome-runtime-sendmessage-or-serviceworker-control

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants