Fix for issue 197: make content script load using manifest key instead of executeScript

This commit is contained in:
Will Bamberg
2017-04-28 10:08:03 -07:00
parent f7c8862703
commit a43eb72e76
2 changed files with 9 additions and 8 deletions

View File

@@ -8,19 +8,13 @@ function getActiveTab() {
function cookieUpdate(tabId, changeInfo, tab) {
getActiveTab().then((tabs) => {
/* inject content script into current tab */
browser.tabs.executeScript(null, {
file: "/content_scripts/updatebg.js"
});
// get any previously set cookie for the current tab
var gettingCookies = browser.cookies.get({
url: tabs[0].url,
name: "bgpicker"
});
gettingCookies.then((cookie) => {
if(cookie) {
if (cookie) {
var cookieVal = JSON.parse(cookie.value);
browser.tabs.sendMessage(tabs[0].id, {image: cookieVal.image});
browser.tabs.sendMessage(tabs[0].id, {color: cookieVal.color});

View File

@@ -36,5 +36,12 @@
"background": {
"scripts": ["background_scripts/background.js"]
}
},
"content_scripts": [
{
"matches": ["<all_urls>"],
"js": ["content_scripts/updatebg.js"]
}
]
}