Is it possible to invoke flashgot from another firefox addon

General discussion about the FlashGot extension for Firefox
Post Reply
kneo
Posts: 4
Joined: Mon Nov 18, 2013 3:43 am

Is it possible to invoke flashgot from another firefox addon

Post by kneo »

Hi,

I'm writing a firefox addon, which could generate some addresses dynamically. So I'd like to invoke flashgot to download them from my addon. Is it possible?
BTW: I want it automatic, not generating a dynamic page and asking user to use flashgot manually.

Thanks,
Kneo
Mozilla/5.0 (Windows NT 6.1; WOW64; rv:25.0) Gecko/20100101 Firefox/25.0
kneo
Posts: 4
Joined: Mon Nov 18, 2013 3:43 am

Re: Is it possible to invoke flashgot from another firefox a

Post by kneo »

I'm able to get flashgot-service successfully right now. I guess it can be used to start a download. Still investigating...

Code: Select all

{Cc, Ci} = require("chrome")
gFlashGotService = Cc["@maone.net/flashgot-service;1"].getService().wrappedJSObject
Mozilla/5.0 (Windows NT 6.1; WOW64; rv:25.0) Gecko/20100101 Firefox/25.0
User avatar
Giorgio Maone
Site Admin
Posts: 9454
Joined: Wed Mar 18, 2009 11:22 pm
Location: Palermo - Italy
Contact:

Re: Is it possible to invoke flashgot from another firefox a

Post by Giorgio Maone »

There's no officially supported API, but something like this should work:

Code: Select all


let flashGotService = Cc["@maone.net/flashgot-service;1"].getService().wrappedJSObject

let links = {
  __proto__: Array.prototype, // very important, or use let links=[] and add expandoes later
  document: window.content.document, // optional, the document containing the links
  referrer: window.content.location.href, // optional, or inferred from document
  postData: "param1=something&param2=something+else", // optional
}

links.push({
  href: "http://xyz.com/clip.avi",
  description: "Some description", // optional, used by UI
  fname: "Forced_file_name.avi", // optional, overrides href URL's file name
  postData: "param1=something&param2=something+else", // optional, overrides links.postData
});

links.push(anotherLinkObject);

flashgotService.download(links);
Mozilla/5.0 (Windows NT 6.1; WOW64; rv:25.0) Gecko/20100101 Firefox/25.0
kneo
Posts: 4
Joined: Mon Nov 18, 2013 3:43 am

Re: Is it possible to invoke flashgot from another firefox a

Post by kneo »

Many thanks! It's exactly what I wanted to know!
Giorgio Maone wrote:There's no officially supported API, but something like this should work:

Code: Select all


let flashGotService = Cc["@maone.net/flashgot-service;1"].getService().wrappedJSObject

let links = {
  __proto__: Array.prototype, // very important, or use let links=[] and add expandoes later
  document: window.content.document, // optional, the document containing the links
  referrer: window.content.location.href, // optional, or inferred from document
  postData: "param1=something&param2=something+else", // optional
}

links.push({
  href: "http://xyz.com/clip.avi",
  description: "Some description", // optional, used by UI
  fname: "Forced_file_name.avi", // optional, overrides href URL's file name
  postData: "param1=something&param2=something+else", // optional, overrides links.postData
});

links.push(anotherLinkObject);

flashgotService.download(links);
Mozilla/5.0 (Windows NT 6.1; WOW64; rv:25.0) Gecko/20100101 Firefox/25.0
kneo
Posts: 4
Joined: Mon Nov 18, 2013 3:43 am

Re: Is it possible to invoke flashgot from another firefox a

Post by kneo »

For some reason, the '__proto__: Array.prototype' style doesn't work for me, but '[]' does work.
When I use '__proto__: Array.prototype', the external download tool can be launched, but nothing is downloaded.
Mozilla/5.0 (Windows NT 6.1; WOW64; rv:25.0) Gecko/20100101 Firefox/25.0
syed20
Posts: 1
Joined: Sat Sep 06, 2014 6:54 am

Re: Is it possible to invoke flashgot from another firefox a

Post by syed20 »

I'm able to get flashgot-service successfully right now. I guess it can be used to start a download. Still investigating...
Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.103 Safari/537.36
Post Reply