Skip to content

Commit

Permalink
Merge pull request #3 from torikulhabib/master
Browse files Browse the repository at this point in the history
Update background.js
  • Loading branch information
torikulhabib committed Jan 5, 2022
2 parents 5bfda31 + 12adf18 commit de36150
Showing 1 changed file with 25 additions and 14 deletions.
39 changes: 25 additions & 14 deletions background.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@
* Authored by: torikulhabib <torik.habib@Gmail.com>
*/

let GabutDownload, result;
let GabutDownload, result, frfx;
let CustomPort = false;
let interruptDownloads = true;
let PortSet = "2021";
let HostDownloader = "http://127.0.0.1:"+PortSet;

if (typeof browser !== 'undefined') {
GabutDownload = browser;
frfx = true;
} else if (typeof chrome !== 'undefined') {
GabutDownload = chrome;
}
Expand All @@ -50,28 +51,38 @@ async function alwawscheck () {
}, 2000);
}

GabutDownload.downloads.onCreated.addListener(function (downloadItem) {
GabutDownload.downloads.onCreated.addListener (function (downloadItem) {
if (!interruptDownloads) {
return;
}
if (result != "OK") {
return;
}
});

GabutDownload.downloads.onDeterminingFilename.addListener((downloadItem)=> {
if (!interruptDownloads) {
return;
}
if (result != "OK") {
return;
if (frfx) {
SendToOniDM (downloadItem);
setTimeout (()=> {
GabutDownload.downloads.cancel (downloadItem.id);
GabutDownload.downloads.erase({ id: downloadItem.id });
}, -1);
}
setTimeout (()=> {
GabutDownload.downloads.cancel (downloadItem.id);
}, -1);
SendToOniDM (downloadItem);
});

if (!frfx) {
GabutDownload.downloads.onDeterminingFilename.addListener ((downloadItem)=> {
if (!interruptDownloads) {
return;
}
if (result != "OK") {
return;
}
SendToOniDM (downloadItem);
setTimeout (()=> {
GabutDownload.downloads.cancel (downloadItem.id);
GabutDownload.downloads.erase ({ id: downloadItem.id });
}, -1);
});
}

function SendToOniDM (downloadItem) {
var xmlrequest = new XMLHttpRequest ();
var content = "link:" + (downloadItem['finalUrl']||downloadItem['url']);
Expand Down

0 comments on commit de36150

Please sign in to comment.