@@ -47,7 +47,7 @@ async function RunScript (tabId, callback) {
47
47
let existid = false ;
48
48
let scripts = await browser . scripting . getRegisteredContentScripts ( ) ;
49
49
for ( let scrid of scripts . map ( ( script ) => script . id ) ) {
50
- if ( `${ tabId } ` === scrid ) {
50
+ if ( `${ tabId } ` == scrid ) {
51
51
existid = true ;
52
52
}
53
53
}
@@ -61,21 +61,18 @@ async function StopScript (tabId) {
61
61
browser . tabs . onUpdated . addListener ( ( tabId , changeInfo , tab ) => {
62
62
if ( DownloadVideo ) {
63
63
if ( changeInfo . status == 'loading' ) {
64
+ browser . webRequest . onResponseStarted . addListener ( WebContent , { urls : [ '<all_urls>' ] } , [ 'responseHeaders' ] ) ;
64
65
RunScript ( tabId , function ( existid ) {
65
66
if ( ! existid ) {
66
67
browser . scripting . registerContentScripts ( [ { id : `${ tabId } ` , allFrames : false , matches : [ '<all_urls>' ] , js : [ 'content-script.js' ] , css : [ 'content-script.css' ] } ] ) ;
67
68
}
68
69
} ) ;
69
70
browser . webRequest . onResponseStarted . removeListener ( WebContent ) ;
70
71
browser . tabs . sendMessage ( tabId , { message : 'gdmclean' } ) . then ( function ( ) { } ) . catch ( function ( ) { } ) ;
72
+ browser . webRequest . onResponseStarted . addListener ( WebContent , { urls : [ '<all_urls>' ] } , [ 'responseHeaders' ] ) ;
71
73
}
72
- browser . webRequest . onResponseStarted . addListener ( WebContent , { urls : [ '<all_urls>' ] } , [ 'responseHeaders' ] ) ;
73
74
} else {
74
- RunScript ( tabId , function ( existid ) {
75
- if ( existid ) {
76
- StopScript ( tabId ) ;
77
- }
78
- } ) ;
75
+ StopScript ( tabId ) ;
79
76
}
80
77
} ) ;
81
78
@@ -219,12 +216,18 @@ browser.runtime.onMessage.addListener((request, sender, callback) => {
219
216
load_conf ( ) ;
220
217
} else if ( request . extensionId == "gdmurl" ) {
221
218
if ( ! InterruptDownloads || ResponGdm ) {
219
+ downloadfirefox ( request . message ) ;
222
220
return ;
223
221
}
224
222
fetch ( get_host ( ) , { method : 'post' , body : request . message } ) . then ( function ( r ) { return r . text ( ) ; } ) . catch ( function ( ) { } ) ;
225
223
}
226
224
} ) ;
227
225
226
+ async function downloadfirefox ( urls ) {
227
+ let url = urls . substring ( 5 , urls . lastIndexOf ( ",filename:" ) ) ;
228
+ await browser . downloads . download ( { url : url } ) ;
229
+ }
230
+
228
231
get_host = function ( ) {
229
232
if ( CustomPort ) {
230
233
return `http://127.0.0.1:${ PortSet } ` ;
0 commit comments