我有一个简单的Javascript小书签,将其放在一起即可针对外部工具运行适当的GitHub存储库的内容:
javascript:(function(){
var isApex = false;
var sourceLangs = document.getElementsByClassName('lang');
for (var i = 0; i < sourceLangs.length; ++i) {
var l = sourceLangs[i];
if(l.innerHTML == 'Apex') {
isApex = true;
// alert('This is an Apex repo');
}
}
if(location.hostname != 'github.com' || isApex == false) {
alert('This is not a GitHub Apex repository!');
}
else {
window.open('https://githubsfdeploy.herokuapp.com/app/githubdeploy'+location.pathname);
}
})();
Run Code Online (Sandbox Code Playgroud)
当我在Chrome或IE中运行它(通过Daring Fireball的JS小书签生成器运行它后,它可以正常工作。在Firefox中,它会生成内容安全策略错误:
[15:33:19.318] Content Security Policy: Directive inline script base restriction violated @ https://github.com/Groundwire/Campaign-Combiner
Run Code Online (Sandbox Code Playgroud)
我已经阅读了有关这个主题的SE问题,以及有关CSP的github博客文章 …