您需要注入2个内容脚本:
"content_scripts": [
{
"matches": ["http://www.example.com/*"],
"js": ["example.js"]
},{
"matches": ["http://www.rapidshare.com/*"],
"all_frames": true,
"js": ["rapidshare.js"]
}
]
为了将链接从一个脚本传输到另一个脚本,您需要通过后台页面进行通信:
rapidshare.js:
chrome.runtime.sendMessage({url: "link"})
background.js:
chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) {
chrome.tabs.sendMessage(sender.tab.id, request);
sendResponse({});
});
example.js:
chrome.runtime.onRequest.addListener(function(request, sender, sendResponse) {
console.log("received url:", request.url);
sendResponse({});
});