Github有以下内容内容安全政策 https://w3c.github.io/webappsec/specs/content-security-policy/:
内容安全策略:默认-src *;脚本-src
asset-cdn.github.com www.google-analytics.com
收集器-cdn.github.com;对象-src 资产-cdn.github.com;样式-src
'自我' '不安全内联' '不安全评估' asset-cdn.github.com; img 源文件
“自我”数据:assets-cdn.github.com identicons.github.com
www.google-analytics.com Collector.githubapp.com
*.githubusercontent.com *.gravatar.com *.wp.com;媒体-src“无”; frame-src 'self' render.githubusercontent.com www.youtube.com
player.vimeo.com checkout.paypal.com;字体-src资产-cdn.github.com;
connect-src 'self' ghconduit.com:25035 live.github.com
uploads.github.com s3.amazonaws.com
我们可以使用 Evernote 或 Pocket 等服务的浏览器扩展从网络上剪辑/检索内容。
我在此 Github 政策中没有看到任何提及 Pocket 或 Evernote 的内容。有人可以解释一下为什么 Pocket 扩展能够从 Github 检索内容,而 Evernote 扩展却不能,有一个CSP错误 https://discussion.evernote.com/topic/64966-github-no-web-clipping/)
CSP 策略是否可以阻止加载小书签应用程序或浏览器扩展应用程序(例如 Clipper)?如果是这样,Pocket 如何才能使其扩展适用于任何内容?
我们的小书签/扩展程序中存在这个问题,我希望它们像 Pocket 扩展程序一样顺利工作,但我真的不知道从哪里开始......谢谢
Edit:
当人们在评论中询问代码时,我们的书签会加载以下 javascript:
javascript: (function() {
function loadScript(a, b) {
var c = document.createElement('script');
c.type = 'text/javascript';
c.src = a;
var d = document.getElementsByTagName('head')[0],
done = false;
c.onload = c.onreadystatechange = function() {
if (!done && (!this.readyState || this.readyState == 'loaded' || this.readyState == 'complete')) {
done = true;
b()
}
};
d.appendChild(c)
}
loadScript('http://localhostsss.com:9000/assets/js/backbone/views/clipping/clippinglocal.js', function() {
s.clipping.initClipping()
})
})()
如果我尝试在具有 CSP 的中型页面中启动此小书签,则会收到以下错误。
拒绝加载脚本
'http://localhostssss.com:9000/assets/js/backbone/views/clipping/clippinglocal.js http://localhostssss.com:9000/assets/js/backbone/views/clipping/clippinglocal.js'
因为它违反了以下内容安全策略指令:
“script-src 'unsafe-eval' 'unsafe-inline' 关于:
https://.akamaihd.net http://.baidu.comhttps://bitly.com https://bitly.comhttps://.cloudfront.net https://.facebook.com https://.facebook.nethttps://getpocket.com https://getpocket.comhttps://.github.com https://.googleapis.comhttps://ssl.google-analytics.com https://ssl.google-analytics.com https://app.greenhouse.io https://app.greenhouse.iohttps://.medium.comhttps://myspace.com https://myspace.comhttps://.pinterest.comhttps://www.readability.com https://www.readability.com https://thinkery.me https://thinkery.me https://this.cm https://this.cmhttps://.twitter.comhttps://use.typekit.net https://use.typekit.nethttps://*.instapaper.com
'自己'”。
有人可以告诉我如何使我们的书签可在具有 CSP 策略的 Medium 或 Github 等网站上加载。
我还不能过多谈论浏览器扩展,因为我还没有开发它,而且这个人也不在这里。我只知道我们有同样的问题,我们的浏览器扩展基本上与我们的书签相同的代码,只是它稍微适应了浏览器扩展外壳。如果您只能回答小书签的情况,我会同意并接受答案,但任何有关浏览器扩展的提示也很好:)