我试图将iframe注入到Google主页中。
我使用此代码注入其他网页,它的工作原理。只有google.com网站不起作用。
我做错了什么?
的manifest.json
{
"manifest_version": 2,
"content_scripts": [ {
"js": [ "content.js" ],
"matches": [ "*://*.google.com/*" ]
} ],
"description": "Inject",
"name": "Inject",
"version": "1.0",
"permissions": [ "*://*.google.com/*", "management", "tabs", "webRequest", "webRequestBlocking" ],
"web_accessible_resources": ["content.html"]
}
content.js
var mhadiv = document.createElement ("iframe");
mhadiv.width = "300px";
mhadiv.height = "300px";
mhadiv.frameBorder = "0";
mhadiv.scrolling = "no";
mhadiv.style.padding = "0";
mhadiv.style.overflow = "hidden";
mhadiv.src = chrome.extension.getURL ("content.html");
document.getElementsByTagName('body')[0].appendChild(mhadiv);
content.html
<html>
<head>
<style type="text/css">
body{
width: 100%;
margin:0;
padding:0;
}
#content {
width: 300px;
height: 300px;
border: 1px solid;
border-color: #e5e6e9 #dfe0e4 #d0d1d5;
border-radius: 3px;
background-color: #fff;
}
</style>
</head>
<body>
<div id="content">
</div>
</body>
</html>