Path to the XPI file for the latest version of my extension?

Talk about add-ons and extension development.
Post Reply
Martin2011
Posts: 5
Joined: October 2nd, 2011, 2:38 am

Path to the XPI file for the latest version of my extension?

Post by Martin2011 »

Hello,

I have added a Firefox extension here:

https://addons.mozilla.org/en-GB/firefo ... y-checkout

and want to add a link to my website so that my users can install it directly without going to the "Firefox Add-ons" store.

I can see how I can just do :

Code: Select all

$('#InstallButton').click(function(event) {
    document.location.href = 'https://addons.mozilla.org/firefox/downloads/file/834794/the_lucky_checkout_shopping_tool-1.6.1-an+fx-windows.xpi';
    event.preventDefault();
    return false;
});
but if I do that then I need to change the code every time I update the extension. Is there a way I can link to the latest version of my extension so that I don't need to remember to update the code every time I update the extension?

Thanks,

Martin
isaacschemm
Posts: 270
Joined: January 20th, 2015, 12:29 pm

Re: Path to the XPI file for the latest version of my extens

Post by isaacschemm »

The addons-server API could help with this. I'll see if I can whip up some jQuery code to get the URL of the newest version.

EDIT: How's this look?

Code: Select all

$.get("https://addons.mozilla.org/api/v3/addons/addon/lucky-checkout/").done(function (addon_info) {
    var files = addon_info.current_version.files;
    var platform = /Android/.test(navigator.userAgent) ? "android"
        : /Windows/.test(navigator.userAgent) ? "windows"
            : /Mac/.test(navigator.userAgent) ? "mac"
                : "linux";
    for (var i = 0; i < files.length; i++) {
        if (files[i].platform == platform || files[i].platform == "all") {
            $('#InstallButton').click(function (event) {
                document.location.href = files[i].url;
                event.preventDefault();
                return false;
            });
            break;
        }
    }
}).fail(function () {
    $('#InstallButton').hide();
});
Martin2011
Posts: 5
Joined: October 2nd, 2011, 2:38 am

Re: Path to the XPI file for the latest version of my extens

Post by Martin2011 »

Cool, I didn't know about that API but thanks, looks like you've nailed it!
nohamelin
Posts: 96
Joined: September 3rd, 2013, 4:04 pm
Location: Chile

Re: Path to the XPI file for the latest version of my extens

Post by nohamelin »

It's possible use something as:
https://addons.mozilla.org/firefox/down ... ock-origin

but by some reason it doesn't seem to work with lucky-checkout... :-k
Brummelchen
Posts: 4480
Joined: March 19th, 2005, 10:51 am

Re: Path to the XPI file for the latest version of my extens

Post by Brummelchen »

and want to add a link to my website so that my users can install it directly without going to the "Firefox Add-ons" store.
eg i dont install addons from other websites than AMO. and thats recommended procedure for any websites to link to AMO rather than own unsecure server. mozilla servers are highly secured - yours not and its hackable. please drop this bad idea.
Post Reply