user2859994
user2859994

Reputation: 49

Chrome Extension - webRequest listener not working

I am writing a Chrome extension that listens to web requests on Google Docs. All of my code worked about a week ago, and when I opened Chrome today to run it again, my webRequest listener no longer functions.

I can see requests going through, but "REQUEST" is never printed to the console. Is this an issue with my code? Could there have been a new Chrome update that caused this to no longer work?

There are some errors that appear in the console of the Google Docs page (not the background page of my extension), I have included a list of them as well.

background.js:

chrome.webRequest.onBeforeRequest.addListener(
      function(request) {
          console.log("REQUEST");
          if (request.url.indexOf('/save?') != -1) {
            var requestBody = request.requestBody;
            var docId = request.url.match("docs\.google\.com\/document\/d\/(.*?)\/save")[1];
            var data = {
              "bundles": requestBody.formData.bundles,
              "timeStamp" : parseInt(request.timeStamp, 10)
            };
        parseData(data);
      }
    },
    { urls: ["*://*.google.com/*"] },
    ['requestBody']
);

manifest.json:

{
  "manifest_version": 2,
  "name": "Document Difficulty Prediction",
  "version": "0.1",
  "background": {
    "scripts": ["background.js"],
    "persistent": true
  },
  "permissions": [
    "webRequest",
    "activeTab",
    "*://*.google.com/"
   ]
}

List of errors in docs.google.com console:

GET chrome-extension://ghbmnnjooekpmoecnnnilnnbdlolhkhi/page_embed_script.js net::ERR_FAILED

jquery.min.js:3 Blocked script execution in docs.google.com/document/d/1tMzarhc5tqcMR8-Rpm_ukJ20pXK2jH8Ekub8HqHP_50/edit because the document's frame is sandboxed and the 'allow-scripts' permission is not set.

Uncaught SecurityError: Blocked a frame with origin clients5.google.com from accessing a frame with origin docs.google.com. Protocols, domains, and ports must match.

(all three of those links in the error messages have https:// before them but I had to delete that because I don't have enough points to have three links in a question)

Upvotes: 2

Views: 2134

Answers (1)

Daniel Herr
Daniel Herr

Reputation: 20438

This is a result of a fix to prevent intercepting requests for other extensions and apps. They accidentally also blocked it for hosted apps. See crbug.com/510802#c60 and crbug.com/526413#c23

Upvotes: 2

Related Questions