我正在做一个非常简单的exstension,当你点击它时,它应该打开一个新标签,并将用户发送到www.simplewebstats.com,如下所示:
http://simplewebstats.com/process.php?domain="Domain the user is browsing"
因此,如果他正在浏览google.com,他应该被发送为
http://simplewebstats.com/process.php?domain=google.com
这就是我所拥有的
的manifest.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
}
background.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]});
});
});
点击没有任何问题,问题出在哪里?我似乎无法找到它
答案 0 :(得分:0)
您可以使用小书签来完成此操作。
javascript: (function() {
var current_domain = window.location.href.replace(/^http\:\/\//,'');
window.location.href = "http://www.simplewebstats.com/process.php?ref=plugins&processType=add&domain=" + current_domain;
})();