I need to open a newtab ( that point to a link that show how to use my extension ) after installing the extension. How can I do that ?
You can have the background page check for a hasSeenIntro
key in local storage on page load, which happens each time the browser loads, and when the browser is installed. If it's there, the user has seen the intro interstitial, and if not, show them the page (using chrome.tabs.create
) then set the key.
Somewhere in your background.html:
if (!window.localStorage.getItem('hasSeenIntro')) {
window.localStorage.setItem('hasSeenIntro', 'yep');
chrome.tabs.create({
url: '/help.html'
});
}
You could extend this to show an intro for each new major version/feature in the extension, by not only checking the presence/absence of the key in local storage, but the value as well (e.g., last-seen feature page).
Be careful with this though, it may get annoying to show a page every time the extension updates itself.
You can use the onInstalled listener. It will open options.html only once when the user install the Chrome extension.
chrome.runtime.onInstalled.addListener(function (){
chrome.tabs.create({url:chrome.extension.getURL("options.html")},function(){})
})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With