MozillaZine

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

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

Post Posted January 11th, 2018, 1:46 pm

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: 268
Joined: January 20th, 2015, 12:29 pm

Post Posted January 11th, 2018, 2:53 pm

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

Post Posted January 13th, 2018, 1:37 pm

Cool, I didn't know about that API but thanks, looks like you've nailed it!

nohamelin
 
Posts: 97
Joined: September 3rd, 2013, 4:04 pm
Location: Chile

Post Posted January 13th, 2018, 7:08 pm

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: 3894
Joined: March 19th, 2005, 10:51 am

Post Posted January 14th, 2018, 3:03 am

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.

Return to Extension Development


Who is online

Users browsing this forum: No registered users and 0 guests