TODO: 解决sendResponse 不能异步等待的问题. 导致数据就完成了一个交互.
This commit is contained in:
		
							parent
							
								
									324322cf23
								
							
						
					
					
						commit
						e9cda54cb8
					
				@ -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);
 | 
			
		||||
 | 
			
		||||
@ -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)
 | 
			
		||||
    }
 | 
			
		||||
  })
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user