machineghost
machineghost

Reputation: 35820

Google Chrome Extension Permissions Issue, With Google Docs (Only)

I have a very simple Chrome Extension. It's basically just:

background.js:

chrome.browserAction.onClicked.addListener(function(tab) {
  chrome.tabs.executeScript({ code: 'alert("hi")' });
});

manifest.json (the relevant parts):

{
  "manifest_version": 2,
  "name": "ABC",
  "version": "0.0.1",
  "description": "abc",
  "background": {
    "scripts": ["background.js"],
    "persistent": false
  },
  "browser_action": {
    "default_title": "Start"
  },
  "permissions": [
    "activeTab",
    "tabs",
    "*://*/*"
  ]
}

The weird thing is that I can use it on most sites and it works perfectly fine: I get the alert as expected, with no errors. However, if I try to use my extension on Google Slides I get:

_generated_background_page.html:1 Unchecked runtime.lastError while running tabs.executeScript: Cannot access contents of url "https://docs.google.com/presentation/d/1_utjr0oy3rpsFq_R2YxAi2qNUIGItpj7ePhBCgqkdRY/edit#slide=id.g36de8e2a97_0_0". Extension manifest must request permission to access this host. at chrome-extension://ijlnhinabondoaapkefkfbkickaemgdl/background.js:55:15

(Line 55 is the line chrome.tabs.executeScript({ code: 'alert("hi")' });)

But since my manifest clearly gives me permission to that host (via the "*://*/*" permissions entry) I have no idea what is causing this error or how to fix it.

Upvotes: 0

Views: 4070

Answers (1)

jgaul
jgaul

Reputation: 601

I unfortunately can't reproduce your issue with that code on my own Slides presentation (the alert runs fine).

Per the comments, I understand neither of these helped:

  1. Trying <all_urls> rather than *://*/* as shown here.
  2. Disabling all other Chrome extensions.

Given that, try this: Create a fresh Chrome profile, load the unpacked extension into that profile, and see if you can reproduce the issue.

If we can't reason with the gremlins, perhaps we can at least contain them.

Upvotes: 2

Related Questions