Chrome extension permissions
cross-origin permissions
Host names in permissions item of manifest.json is for cross-origin permissions of XMLHttpRequest.
By adding hosts or host match patterns (or both) to the permissions section of the manifest file, the extension can request access to remote servers outside of its origin.
{
"name": "My extension",
...
"permissions": [
"http://www.google.com/"
],
...
}
A match pattern of http://*/ allows HTTP access to all reachable domains. Note that here, match patterns are similar to content script match patterns, but any path information following the host is ignored.
Programmatic injection
To insert code into a page, your extension must have cross-origin permissions for the page. It also must be able to use the chrome.tabs module. You can get both kinds of permission using the manifest file’s permissions field.
Once you have permissions set up, you can inject JavaScript into a page by calling tabs.executeScript. To inject CSS, use tabs.insertCSS.
本文介绍了如何在Chrome扩展中设置跨域权限,通过在manifest.json文件中指定远程服务器的主机名来请求跨域访问权限。同时介绍了如何利用chrome.tabs模块注入JavaScript或CSS到页面中。
843

被折叠的 条评论
为什么被折叠?



