Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

How can I open a web page when someone installs my firefox extension?

Go to solution Solved by MotionFlex,

Essentially, what guitargirl15 said. You will also want to check out: https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/runtime/onInstalled. This event handler can be added to your background page, and will fire whenever a user install/update your extension.

 

Something like this:

browser.runtime.onInstalled.addListener(details => { 
    if(details.reason == "install") {
    	browser.tabs.create({
        	url: "https://example.com" //Your page goes here
        });
    }
});

 

You can also store the page inside your extension and use:

browser.runtime.getURL("/path/to/mywebpage.html")

to get a URL for it.

How can I open a new tab with a web page when someone installs my firefox extension so I can show a welcome message?

 

My Laptop: A MacBook Air 

My Desktop: Don’t have one 

My Phone: An Honor 8s (although I don’t recommend it)

My Favourite OS: Linux

My Console: A Regular PS4

My Tablet: A Huawei Mediapad m5 

Spoiler

 

 

 

Link to post
Share on other sites

Essentially, what guitargirl15 said. You will also want to check out: https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/runtime/onInstalled. This event handler can be added to your background page, and will fire whenever a user install/update your extension.

 

Something like this:

browser.runtime.onInstalled.addListener(details => { 
    if(details.reason == "install") {
    	browser.tabs.create({
        	url: "https://example.com" //Your page goes here
        });
    }
});

 

You can also store the page inside your extension and use:

browser.runtime.getURL("/path/to/mywebpage.html")

to get a URL for it.

Link to post
Share on other sites
On 3/5/2021 at 5:00 PM, MotionFlex said:

Essentially, what guitargirl15 said. You will also want to check out: https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/runtime/onInstalled. This event handler can be added to your background page, and will fire whenever a user install/update your extension.

 

Something like this:


browser.runtime.onInstalled.addListener(details => { 
    if(details.reason == "install") {
    	browser.tabs.create({
        	url: "https://example.com" //Your page goes here
        });
    }
});

 

You can also store the page inside your extension and use:


browser.runtime.getURL("/path/to/mywebpage.html")

to get a URL for it.

Thanks super appreciated! It is working! 

My Laptop: A MacBook Air 

My Desktop: Don’t have one 

My Phone: An Honor 8s (although I don’t recommend it)

My Favourite OS: Linux

My Console: A Regular PS4

My Tablet: A Huawei Mediapad m5 

Spoiler

 

 

 

Link to post
Share on other sites
On 3/5/2021 at 5:00 PM, MotionFlex said:

Essentially, what guitargirl15 said. You will also want to check out: https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/runtime/onInstalled. This event handler can be added to your background page, and will fire whenever a user install/update your extension.

 

Something like this:



browser.runtime.onInstalled.addListener(details => { 
    if(details.reason == "install") {
    	browser.tabs.create({
        	url: "https://example.com" //Your page goes here
        });
    }
});

 

You can also store the page inside your extension and use:



browser.runtime.getURL("/path/to/mywebpage.html")

to get a URL for it.

Do you know why isn't this working?

setInterval(function(){browser.runtime.onInstalled.addListener(details => { 
    if(details.reason == "install") {
       browser.tabs.create({
           url: "https://kagi.com/"
        });
    }
 });}, 3000);

 

My Laptop: A MacBook Air 

My Desktop: Don’t have one 

My Phone: An Honor 8s (although I don’t recommend it)

My Favourite OS: Linux

My Console: A Regular PS4

My Tablet: A Huawei Mediapad m5 

Spoiler

 

 

 

Link to post
Share on other sites
7 hours ago, Sandro Linux said:

Do you know why isn't this working?



setInterval(function(){browser.runtime.onInstalled.addListener(details => { 
    if(details.reason == "install") {
       browser.tabs.create({
           url: "https://kagi.com/"
        });
    }
 });}, 3000);

 

I'm not entirely sure what you want to do. I am guessing the reason that code doesn't work is, by the time you add the event listener, the Installed event has already fired. If you want to delay the opening of the webpage, you should delay the call to browser.tabs.create. Also, use setTimeout instead, as setInterval will repeatedly invoke the callback function, every 3000ms in this case until you clear it, whilst setTimeout only calls it once after 3000ms.

 

Like this:

browser.runtime.onInstalled.addListener(details => {
    if (details.reason == "install") {
        setTimeout(() => {
            browser.tabs.create({
                url: "https://kagi.com/"
            });
        }, 3000);
    }
});

 

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×