Can I install the Intercom Messenger within a Chrome extension?
Best answer by Eric Fitz
View originalCan I install the Intercom Messenger within a Chrome extension?
Best answer by Eric Fitz
View originalInside a Chrome extension, installing the Intercom Messenger script will not work out of the box, mainly because of the content security policy.
This kind of installation requires re-formatting those options for the content_security_policy section of the Google Chrome extension manifest.
Here is a small tool to convert them easily:
var s = ` i _can_t_show_you_because_it_contins_more_than_2_links_and_i_am_not_allowed_to_have_them but copy it from the abose csp help page'`;
var o={};
var last=null;
s.split("\n").forEach(l => {
var m;
if(m=l.match(/^\ +(.*)$/)) {
o[last].push(m[1])
}else if(m=l.match(/^(.*)\:$/)){
last = m[1]; o[last] = [];
}
});
s='';
Object.keys(o).forEach(key => {
s+= `${key} ${o[key].join(' ')};`
})
console.log(s);
Eventually, this will output something like:
onnect-src i_can_t_show_you_because_it_contins_more_than_2_links_and_i_am_not_allowed_to_have_them;
This is a good start for the manifest but it will need some additions, mainly related to adding the defaults of your domain or ‘self’ as well as the policies for object-src ‘self’ your_domain_mask;
The final one, for a development environment, looks like this:
"content_security_policy": "object-src 'self' i _can_t_show_you_because_it_contins_more_than_2_links_and_i_am_not_allowed_to_have_them"
Finally, the Intercom Messenger pops up in a window loaded from the chrome-extension:// space.
Hello @eric f11 , could you be more specific on “the abose csp help page”?
What is the proper format of the content_security_policy ?
I have it like this, but it is not working.
Thanks in advance!
did you manage to get this working?
Already have an account? Login
No account yet? Create an account
Enter your username or e-mail address. We'll send you an e-mail with instructions to reset your password.