我创建了一个Chrome扩展程序,可以在文本高亮时找到USPS跟踪号码。我的当前代码运行良好,但我想进行一些修改。
以下是manifest.json文件:
{
"manifest_version": 2,
"background" : { "scripts": ["background.js"] },
"description": "Track on USPS",
"icons": {
"default_icon": "usps.png"
},
"minimum_chrome_version": "29.0",
"name": "USPS",
"permissions": [ "contextMenus", "tabs", "http://*/*",
"https://*/*" ],
"version": "1.0"
}
这是 `background.js` 文件:
/**
* Returns a handler which will open a new tab when activated.
*/
function searchgoogle(info)
{
var searchstring = info.selectionText;
chrome.tabs.create({url: "https://tools.usps.com/go/TrackConfirmAction?qtc_tLabels1=" + searchstring})
}
chrome.contextMenus.create({title: "Search USPS", contexts:["selection"], onclick: searchgoogle});
/**
* Create a context menu which will only show up for images.
*/
chrome.contextMenus.create({
"title" : "Search tracking number on USPS",
"type" : "normal",
"contexts" : ["text"],
"onclick" : getClickHandler()
});
现在我想修改当前的脚本:
https://tools.usps.com/go/TrackConfirmAction?qtc_tLabels1=" + searchstring
使用以下脚本,可以打开一个弹出窗口。我尝试修改了新脚本,但没有成功。有人能帮帮我吗?
以下是我想使用的新脚本:
javascript:new function(){window.open('https://tools.usps.com/go/TrackConfirmAction?qtc_tLabels1=' + window.getSelection().toString(), '_blank', 'toolbar=0,location=0,menubar=0,top=91,height=900,width=650,left=1475');};
非常感谢!这个社区在我的项目中帮了我很多忙。