Intercept HTTP request body from chrome extension

前端 未结 3 1151
清酒与你
清酒与你 2020-12-08 21:36

I\'m aware that chrome.webRequest.onBeforeRequest allows a request to be intercepted, analyzed and blocked, but it only allows access to the request headers, an

3条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-08 21:57

    While you may not be able to intercept, you can use standard AJAX approach to duct-tape it. Instead of making the href request see if you can make an asynchronous call and save it to an HTML object that isn't presented. Then scrape/read/parse/whatever your body criteria is, and if it passes, push that body object back up to the current window/page.

    Storing the content in a suppressed element and then using that same element for content would allow you to avoid making duplicate calls. The downside is that you will get the full content for stuff you won't end up using. That may or may not be a bandwidth/speed performance issue.

提交回复
热议问题