1
0
mirror of https://github.com/chinchang/web-maker.git synced 2025-07-14 10:36:19 +02:00
Files
php-web-maker/src/eventPage.js
2019-07-03 02:59:35 +05:30

48 lines
996 B
JavaScript

function openApp() {
chrome.tabs.create({
url: chrome.extension.getURL('index.html'),
selected: true
});
}
chrome.browserAction.onClicked.addListener(function() {
openApp();
});
// Listen for tabs getting created.
chrome.tabs.onCreated.addListener(function(tab) {
// If a new tab is opened (without any URL), check user's
// replace Tab setting and act accordingly. Default is false.
if (tab.url === 'chrome://newtab/') {
chrome.storage.sync.get(
{
replaceNewTab: false
},
function(items) {
if (items.replaceNewTab) {
chrome.tabs.update(
tab.id,
{
url: chrome.extension.getURL('index.html')
},
function callback() {
console.log('ho gaya');
}
);
}
}
);
}
});
chrome.runtime.onInstalled.addListener(function callback(details) {
if (details.reason === 'install') {
openApp();
}
if (details.reason === 'update') {
if ((details.previousVersion + '').indexOf('1.') === 0) {
openApp();
}
}
});