function notify(notifyMessage) {
var options = {
type: "basic",
title: "My Extension",
message: notifyMessage,
iconUrl: "hello.png"
};
chrome.notifications.create("", options, function(notificationId) {
setTimeout(function(){
chrome.notifications.clear(notificationId, function(){});
}, 2000);
});
chrome.notifications.onClicked.addListener(function(notificationId, byUser) {
chrome.tabs.create({url: "http://www.google.com"});
});
}
With this function, when I run notifyfor the first time and click on the notification, it creates one tab. When I run it a second time and click, it creates two tabs, etc. How can I reorganize my code to create only one tab each time?
source
share