TODO: 解决sendResponse 不能异步等待的问题. 导致数据就完成了一个交互.

This commit is contained in:
eson 2020-11-17 19:59:44 +08:00
parent 324322cf23
commit e9cda54cb8
2 changed files with 6 additions and 6 deletions

View File

@ -19,7 +19,7 @@ chrome.runtime.onMessage.addListener(function (request, sender, sendResponse) {
case BackgroundMsgType.ERROR:
console.log(request, task_manager, sender); // 利用sender tab id 返回正确的任务id
case BackgroundMsgType.GETTASK:
// sendResponse({type: "error"})
console.log(request, task_manager, sender); // 利用sender tab id 返回正确的任务id
}
// sendResponse({type: MsgType.NEWURL, url: "https://playerduo.com/api/playerDuo-service-v2/rip113?lang=en&deviceType=browser"});
GetTask(sender);

View File

@ -19,14 +19,14 @@ function SendContent() {
function GetTask() {
chrome.runtime.sendMessage({ type: BackgroundMsgType.GETTASK }, function (response) {
switch(response.type) {
case BackgroundMsgType.FETCH:
setTimeout(function(){
GetTask();
}, 6000)
case BackgroundMsgType.WAIT:
case InjectMsgType.WAIT:
setTimeout(function(){
GetTask();
}, 1000);
default:
setTimeout(function(){
GetTask();
}, 6000)
}
})
}