javascript - How to override content security policy while including script in browser JS console? -
i trying include jquery on existing website using console way:
var script = document.createelement('script'); script.src = 'http://code.jquery.com/jquery-1.11.1.min.js'; script.type = 'text/javascript'; document.getelementsbytagname('head')[0].appendchild(script);
then got error:
content security policy: page's settings blocked loading of resource @ http://code.jquery.com/jquery-1.11.1.min.js ..
during development might want include external javascript. might not want copy paste entire jquery code since not neat. how override content security policy development purposes?
this useful quick testing. might want convert script writing browser extension later on.
note (update): writing script on existing website , not have control on setting content-security-policy header.
you can turn off csp entire browser in firefox disabling security.csp.enable
in about:config
menu. if this, should use entirely separate browser testing. example, install firefox developer edition alongside normal browser , use testing (and not normal web use).
as alternative, should possible alter content-security-policy
response header before gets browser (via http proxy). possible extensions.
a chrome extension can set own csp own chrome-extension://...
pages, cannot alter csp of normal webpage.
Comments
Post a Comment