I want to create a similar chrome extensions https://chromewebstore.google.com/detail/jetradar-cheap-flights-ai/bbdcobeilglncnnogiogdiagjflekean
I have this code:
<script async src="https://tp.media/content?currency=usd&trs=291038&shmarker=21549&combine_promos=101_7873&show_hotels=true&powered_by=true&locale=en_us&searchUrl=search.jetradar.com&color_button=%2332a8dd&color_icons=%2332a8dd&dark=%23262626&light=%23FFFFFF&secondary=%23FFFFFF&special=%23C4C4C4&color_focused=%2332a8dd&border_radius=0&no_labels=&plain=true&promo_id=7879&campaign_id=100" charset="utf-8"></script>
But it gives out security errors every time:
Refused to load the script 'https://tp.media/content?currency=usd&trs=291038&shmarker=21549&combine_promos=101_7873&show_hotels=true&powered_by=true&locale=en_us&searchUrl=search.jetradar.com&color_button=%2332a8dd&color_icons=%2332a8dd&dark=%23262626&light=%23FFFFFF&secondary=%23FFFFFF&special=%23C4C4C4&color_focused=%2332a8dd&border_radius=0&no_labels=&plain=true&promo_id=7879&campaign_id=100' because it violates the following Content Security Policy directive: "script-src 'self'". Note that 'script-src-elem' was not explicitly set, so 'script-src' is used as a fallback.
I tried different ways, but nothing helped(
2
Answers
In Manifest V3, executing external scripts directly in the context of an extension is not allowed, but you are still allowed to display external content through a web page loaded into an iframe, provided that the iframe loads a resource accessible over HTTPS.
So, you can create an HTML page that will be embedded as an iframe in the popup extension and on which your external script will be placed.
Create the following files for your extension: (It is assumed that you have a file widget.html , accessible via HTTPS on any server.)
Replace https://yourserver.com/widget.html to the actual URL where your widget.html the page.
All is work with manifest V3! Thanks!
Update Content Security Policy (CSP)
you can update it to allow scripts from the specified domain.
add ‘https://tp.media’