use tab.id

This commit is contained in:
Nils Norman Haukås 2016-08-10 22:31:45 +02:00
parent e8f4eb035e
commit df831fc1b0

View file

@ -1,12 +1,12 @@
chrome.browserAction.onClicked.addListener(function () {
chrome.browserAction.onClicked.addListener(function (tab) {
isMenuOpen(function (responseIsItOpen) {
if (responseIsItOpen) {
console.log('Closing menu');
chrome.tabs.reload();
} else {
console.log('Opening menu');
injectIframe();
injectIframe(tab);
}
})
});
@ -17,13 +17,12 @@ function isMenuOpen(callback) {
});
}
function injectIframe() {
function injectIframe(tab) {
chrome.tabs.executeScript(null, {
chrome.tabs.executeScript(tab.id, {
file: 'app.js'
}, () => {
chrome.tabs.insertCSS(null, {
chrome.tabs.insertCSS(tab.id, {
file: 'style.css',
allFrames: true
});