Google Chrome Extension - prevent cookie on jquery ajax request or Use a chome.extension

前端 未结 2 1452
盖世英雄少女心
盖世英雄少女心 2021-01-15 03:07

I have a great working chrome extension now.

It basically loops over a list of HTML of a web auction site, if a user has not paid for to have the image shown in the

相关标签:
2条回答
  • 2021-01-15 03:42

    You can use the webRequest API to intercept and modify requests (including blanking headers). It cannot be used to modify requests which are created within the context of a Chrome extension though. If you want to use this API for cookie-blanking purposes, you have to load the page in a non-extension context. Either by creating a new tab, or use an off-screen tab (using the experimental offscreenTabs API.

    Another option is to use the chrome.cookie API, and bind a onChanged event. Then, you can intercept cookie modifications, and revert the changes using chrome.cookies.set.

    The last option is to create a new window+tab in Incognito mode. This method is not reliable, and should not be used:

    • The user can disallow access to the Incognito mode
    • The user could have navigated to the page in incognito mode, causing cookie fields to be populated.
    • It's disruptive: A new window is created.
    0 讨论(0)
  • 2021-01-15 03:45

    Presumably this AJAX interaction is being run from a content script? Could you run it from the background page instead and pass the data to the content script? I belive the background page operates in a different context and shouldn't send the normal cookies.

    0 讨论(0)
提交回复
热议问题