1
0
mirror of https://github.com/chinchang/web-maker.git synced 2025-07-16 11:36:20 +02:00

add settings for replace tab.

This commit is contained in:
Kushagra Gour
2016-06-30 04:08:06 +05:30
parent c87aee8bb9
commit 1ef7ec30c6
3 changed files with 24 additions and 11 deletions

View File

@ -5,17 +5,21 @@ chrome.browserAction.onClicked.addListener(function(){
});
});
// Listen for tabs getting created.
chrome.tabs.onCreated.addListener(function (tab) {
console.log('created', arguments)
// If a new tab is opened (without any URL), check user's
// replace Tab setting and act accordingly.
if (tab.url === 'chrome://newtab/') {
chrome.tabs.update(tab.id, {
url: chrome.extension.getURL('index.html')
}, function callback() {
console.log('ho gaya');
chrome.storage.sync.get({
replaceNewTab: true
}, function(items) {
if (items.replaceNewTab) {
chrome.tabs.update(tab.id, {
url: chrome.extension.getURL('index.html')
}, function callback() {
console.log('ho gaya');
});
}
});
}
});
chrome.tabs.onUpdated.addListener(function () {
console.log('updated', arguments)
});