I am trying to create an extension to set certain settings on chrome such as popups etc.
I asked for contentSettings
permission in my manifesto :
"permissions": [
"tabs", "http://*/*", "https://*/*","contentSettings"
],
and I have the following js code to change the settings
var url = 'http://google.com';
var pattern = /^file:/.test(url) ? url : url.replace(/\/[^\/]*?$/, '/*');
var setting = 'popups';
console.log(' setting for '+pattern+': '+setting);
chrome.contentSettings[setting].set({
'primaryPattern': pattern,
'setting': 'allow'
});
and I get the following error in my console:
Uncaught TypeError: Cannot read property 'popups' of undefined
What am I doing wrong?
Most chrome.* APIs are not available to content scripts. They can only be used from background or event pages, popups, or other extension views you define. If you need to initiate your action in response to something that depends on the contents of a page, you can send a message from your content script to a background or event page to carry it out.