我正在制作一个非常简单的扩展程序,当您单击它时,它应该会打开一个新选项卡,并将用户发送到 www.simplewebstats.com,如下所示:
http://simplewebstats.com/process.php?domain="Domain the user is browsing"
因此,如果他正在浏览 google.com,他应该被发送为
http://simplewebstats.com/process.php?domain=google.com
这是我所拥有的
清单.json
{
"background_page": "background.html",
"browser_action": {
"default_icon": "icon.png"
},
"description": "A free SEO tool for webmasters to track and display web data from most websites. ",
"name": "SimpleWebStats Site Report",
"permissions": [ "tabs", "http://www.simplewebstats.com/" ],
"version": "1.2",
"manifest_version": 2
}
背景.html
<script src="js.js"></script>
js.js
chrome.browserAction.onClicked.addListener(function(tab){
chrome.tabs.getSelected(null,function(tab){
chrome.tabs.create({url:"http://www.simplewebstats.com/process.php?ref=plugins& processType=add&domain="+tab.url.match(/:\/\/(.[^/]+)/)[1]});
});
});
点击没有任何反应,问题出在哪里?我似乎找不到它