mirror of
https://github.com/mdn/webextensions-examples.git
synced 2026-04-16 06:18:35 +02:00
Fix for issue 197: make content script load using manifest key instead of executeScript
This commit is contained in:
@@ -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});
|
||||
|
||||
@@ -36,5 +36,12 @@
|
||||
|
||||
"background": {
|
||||
"scripts": ["background_scripts/background.js"]
|
||||
}
|
||||
},
|
||||
|
||||
"content_scripts": [
|
||||
{
|
||||
"matches": ["<all_urls>"],
|
||||
"js": ["content_scripts/updatebg.js"]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user