I want to run a content script on an iframe with a chrome-extension:// URL. I added a line to my manifest.json that I copied out of the documentation http://code.google.com/
I'm having the exact same problem, look at the API http://code.google.com/chrome/extensions/match_patterns.html it says clearly that they accept chrome-extension://*/*
yet they don't.
They need to update the API so as not to confuse people.
You can inject js to your iframe html(chrome-extension:
pages) without declaring it in manifast.json
. The injected js can visit Chrome APIs directly.
iframe.html:
<!DOCTYPE html>
<html>
<head>
...
</head>
<body>
...
</body>
<script src="iframe.js"></script>
</html>
iframe.js:
console.log(chrome); // {loadTimes: ƒ, csi: ƒ, …}
It seems that Chrome authors have silently removed the ability for content scripts to be injected into chrome-extension:
pages. Documentation still says that it works and even contains examples with chrome-extension: scheme but actually it doesn't work. So now only http:
, https:
and ftp:
work "from the box" and file:
can work if user of your extension has enabled this on Extensions (chrome://extensions/) page.
Update: now documentation referred above is updated and says nothing about ability to inject content scripts to chrome-extension:
pages.
No. Only ftp:
, file:
, http:
and https:
can be matched by a content script declaration.
Invalid URL patterns at any of the matches
and exclude_matches
fields are rejected (generating an error when trying to load the extension).
Invalid patterns at the permissions option in the manifest file are ignored.
If you want to run a script on a tab from your extension, use chrome.extension.getViews in your background script. Even better, design your extension's pages such that they effectively communicate with each other (example).