@@ -577,18 +577,21 @@ export class ScriptManager extends Manager {
577577 }
578578
579579 public stopScript ( msg : any ) : Promise < boolean > {
580- return new Promise ( async resolve => {
581- const script = await this . scriptModel . findById ( msg . scriptId ) ;
582- if ( ! script ) {
583- return resolve ( false ) ;
584- }
585- if ( script . type == SCRIPT_TYPE_CRONTAB || script . type == SCRIPT_TYPE_BACKGROUND ) {
586- await this . background . stopScript ( script , msg . isdebug ) ;
587- this . setRunComplete ( script . id )
588- resolve ( true ) ;
589- } else {
590- resolve ( false ) ;
580+ return new Promise ( resolve => {
581+ const handler = async ( ) => {
582+ const script = await this . scriptModel . findById ( msg . scriptId ) ;
583+ if ( ! script ) {
584+ return resolve ( false ) ;
585+ }
586+ if ( script . type == SCRIPT_TYPE_CRONTAB || script . type == SCRIPT_TYPE_BACKGROUND ) {
587+ await this . background . stopScript ( script , msg . isdebug ) ;
588+ void this . setRunComplete ( script . id )
589+ resolve ( true ) ;
590+ } else {
591+ resolve ( false ) ;
592+ }
591593 }
594+ void handler ( ) ;
592595 } ) ;
593596 }
594597
@@ -655,7 +658,7 @@ export class ScriptManager extends Manager {
655658 const filter : ScriptCache [ ] = [ ] ;
656659
657660 let matchScript = runMatchScript . get ( detail . tab . id ) ;
658- if ( ! matchScript ) {
661+ if ( ! matchScript || ! detail . frameId ) {
659662 matchScript = new Map ( ) ;
660663 runMatchScript . set ( detail . tab . id , matchScript ) ;
661664 }
@@ -672,7 +675,7 @@ export class ScriptManager extends Manager {
672675 filter . push ( script ) ;
673676 } ) ;
674677 // 注入框架
675- chrome . tabs . executeScript ( detail . tab . id , {
678+ void chrome . tabs . executeScript ( detail . tab . id , {
676679 frameId : detail . frameId ,
677680 code : `(function(){
678681 let temp = document.createElement('script');
@@ -693,13 +696,13 @@ export class ScriptManager extends Manager {
693696 chrome . browserAction . getBadgeText ( {
694697 tabId : detail . tab ?. id ,
695698 } , res => {
696- chrome . browserAction . setBadgeText ( {
699+ void chrome . browserAction . setBadgeText ( {
697700 text : ( filter . length + ( parseInt ( res ) || 0 ) ) . toString ( ) ,
698701 tabId : detail . tab ?. id ,
699702 } ) ;
700703 } ) ;
701704
702- chrome . browserAction . setBadgeBackgroundColor ( {
705+ void chrome . browserAction . setBadgeBackgroundColor ( {
703706 color : [ 255 , 0 , 0 , 255 ] ,
704707 tabId : detail . tab ?. id ,
705708 } ) ;
@@ -725,7 +728,7 @@ export class ScriptManager extends Manager {
725728 runAt = 'document_idle' ;
726729 break ;
727730 }
728- chrome . tabs . executeScript ( detail . tab ! . id ! , {
731+ void chrome . tabs . executeScript ( detail . tab ! . id ! , {
729732 frameId : detail . frameId ,
730733 code : `(function(){
731734 let temp = document.createElement('script');
0 commit comments