我目前的代碼如下。然而,這只是繼續循環,我不知道爲什麼會發生。Chrome擴展迴路
chrome.runtime.onMessage.addListener(function(request, sender) {
url = request.url;
UName = request.username;
PWord = request.password;
chrome.tabs.update(sender.tab.id, {url: request.redirect});
chrome.tabs.onUpdated.addListener(function (changeInfo) {
chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
chrome.tabs.sendMessage(tabs[0].id, {message: "hello", username: UName, password: PWord}, function(response) {
});
chrome.tabs.onUpdated.removeListener();
return;
});
});
});
您正在向它自己發送一條消息嗎? –
我正在從content.js發送消息到background.js,然後在重定向之後它將消息發送回content.js – user2755352