I'm particularly referring to this https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/theme/getCurrent javascript method as i want to see information about the current theme I'm using on the browser. But when I for ex: call the function in console.log I see no output in the devtools console.
I have tried printing normal debugging statements on the console and they work fine. The method says it returns a promise
. I'm guessing maybe there's a special way to handle them. I just want to see the contents of theme
object so that I can manipulate it.
console.log(browser.theme.getCurrent());
console.log(theme.colors);
function getStyle(themeInfo)
{
if (themeInfo.colors)
{
console.log("accent color : " + themeInfo.colors.accentcolor);
console.log("toolbar : " + themeInfo.colors.toolbar);
}
}
async function getCurrentThemeInfo()
{
var themeInfo = await browser.theme.getCurrent();
getStyle(themeInfo);
}
getCurrentThemeInfo();
manifest.json
{
"manifest_version": 2,
"name": "test",
"version": "1.0",
"description": "tests the theme detecting abilities in Firefox",
"permissions": ["theme"],
"content_scripts": [
{
"matches": ["*://*.mozilla.org/*"],
"js": ["check-theme.js"]
}
]
"applications": {
"gecko": {
"id": "theme@example.org"
}
}
}
I have tried these above codes. First one is just naively trying to print the contents of theme
and the second one is an example from the MDN page(link above). Both output nothing.