Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to load an external JavaScript inside an extension popup

I'm trying to build a page action extension and need to load an external JavaScript library from the popup (it needs to come from the external domain so that the correct cookies are sent).

However I get this error message:

Refused to load script from 'http://api.flattr.com/js/0.6/load.js?mode=auto' because of Content-Security-Policy.

Is there any way around this?

like image 857
pthulin Avatar asked Dec 12 '11 17:12

pthulin


People also ask

How do I call an external JavaScript file?

To include an external JavaScript file, we can use the script tag with the attribute src . You've already used the src attribute when using images. The value for the src attribute should be the path to your JavaScript file. This script tag should be included between the <head> tags in your HTML document.

What is the file extension used for external JavaScript?

External JavaScript External scripts are practical when the same code is used in many different web pages. JavaScript files have the file extension .js.


1 Answers

Using scripts via plain HTTP is no longer allowed for security reasons. See this issue.

From linked page:

Yeah, we're no longer allowing insecure scripts in extensions. If you load a script over HTTP, an active network attacker can inject script into your extension, which is a security vulnerability.

One suggested solution is to link the scripts via HTTPS where possible. Another one is to include the script with the plugin itself.

like image 152
Goran Jovic Avatar answered Sep 22 '22 11:09

Goran Jovic