1
0
mirror of https://github.com/chinchang/web-maker.git synced 2025-07-25 07:51:12 +02:00
Files
php-web-maker/src/eventPage.js
2024-02-20 10:59:51 +05:30

48 lines
988 B
JavaScript

function openApp() {
chrome.tabs.create({
url: chrome.runtime.getURL('index.html'),
selected: true
});
}
chrome.action.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.runtime.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();
}
}
});