Skip to content

Commit 4d66257

Browse files
authored
Merge pull request #18 from torikulhabib/master
ff
2 parents a564b54 + 12a5372 commit 4d66257

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

background.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ async function RunScript (tabId, callback) {
4747
let existid = false;
4848
let scripts = await browser.scripting.getRegisteredContentScripts();
4949
for (let scrid of scripts.map((script) => script.id)) {
50-
if (`${tabId}` === scrid) {
50+
if (`${tabId}` == scrid) {
5151
existid = true;
5252
}
5353
}
@@ -61,21 +61,18 @@ async function StopScript (tabId) {
6161
browser.tabs.onUpdated.addListener((tabId, changeInfo, tab)=> {
6262
if (DownloadVideo) {
6363
if (changeInfo.status == 'loading') {
64+
browser.webRequest.onResponseStarted.addListener (WebContent, {urls: ['<all_urls>']}, ['responseHeaders']);
6465
RunScript (tabId, function (existid) {
6566
if (!existid) {
6667
browser.scripting.registerContentScripts([{id: `${tabId}`, allFrames: false, matches: ['<all_urls>'], js: ['content-script.js'], css: ['content-script.css']}]);
6768
}
6869
});
6970
browser.webRequest.onResponseStarted.removeListener (WebContent);
7071
browser.tabs.sendMessage(tabId, {message: 'gdmclean'}).then (function () {}).catch(function() {});
72+
browser.webRequest.onResponseStarted.addListener (WebContent, {urls: ['<all_urls>']}, ['responseHeaders']);
7173
}
72-
browser.webRequest.onResponseStarted.addListener (WebContent, {urls: ['<all_urls>']}, ['responseHeaders']);
7374
} else {
74-
RunScript (tabId, function (existid) {
75-
if (existid) {
76-
StopScript (tabId);
77-
}
78-
});
75+
StopScript (tabId);
7976
}
8077
});
8178

@@ -219,12 +216,18 @@ browser.runtime.onMessage.addListener((request, sender, callback) => {
219216
load_conf ();
220217
} else if (request.extensionId == "gdmurl") {
221218
if (!InterruptDownloads || ResponGdm) {
219+
downloadfirefox (request.message);
222220
return;
223221
}
224222
fetch (get_host (), { method: 'post', body: request.message }).then (function (r) { return r.text (); }).catch (function () {});
225223
}
226224
});
227225

226+
async function downloadfirefox (urls) {
227+
let url = urls.substring (5, urls.lastIndexOf(",filename:"));
228+
await browser.downloads.download({url: url});
229+
}
230+
228231
get_host = function () {
229232
if (CustomPort) {
230233
return `http://127.0.0.1:${PortSet}`;

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"description": "Integration for Gabut Download Manager.",
44
"short_name": "GabutDM",
55
"homepage_url": "https://github.com/gabutakut/gabutextentionsFF",
6-
"version": "2.6.1",
6+
"version": "2.6.2",
77
"manifest_version": 3,
88
"icons": {
99
"32": "icons/icon_32.png",

popup/popup.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
<div id="Content0" class="tab-pane active">
3636
<div class="tittle">Gabut Download Manager</div>
3737
<img id="img-icon" src="../icons/icon_128.svg" /></h5>
38-
<div class="tittle">Version 2.6.1</div>
38+
<div class="tittle">Version 2.6.2</div>
3939
</div>
4040
<div id="Content1" class="tab-pane">
4141
<div class="tittle">Interrupt Download</div>

0 commit comments

Comments
 (0)