【问题标题】:How to insert javascript to enable MathJax on GitHub wiki pages?如何在 GitHub wiki 页面上插入 javascript 以启用 MathJax?
【发布时间】:2013-05-29 04:07:35
【问题描述】:

GitHub wiki 页面不再支持 MathJax。似乎dotjs Chrome extension 可能是在这些页面上启用 MathJax 的一种方式。

这是我第一次尝试创建将在 github.com 页面上执行的 JavaScript,并插入启用 MathJax 所需的正确代码:

[~]$ cat .js/github.com.js
(function () {
  var script = document.createElement("script");
  script.type = "text/javascript";
  script.src = "https://c328740.ssl.cf1.rackcdn.com/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML";
  document.getElementsByTagName("head")[0].appendChild(script);
 })();

但这不起作用,Chrome JavaScript 控制台中会出现以下错误:

Uncaught EvalError: Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: "script-src 'self'
https://github.com https://a248.e.akamai.net https://jobs.github.com https://ssl.google-analytics.com https://secure.gaug.es https://collector.githubapp.com https://gist.github.com".
    c328740.ssl.cf1.rackcdn.com/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML:29

什么是正确的 JavaScript?

【问题讨论】:

标签: javascript google-chrome mathjax dotjs


【解决方案1】:

我认为问题出在 MathJax 的源代码中,因为它在那里使用了 eval 函数

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-08-02
    • 2014-03-10
    • 1970-01-01
    • 2014-07-13
    • 2017-05-02
    • 1970-01-01
    • 2014-04-05
    • 2023-03-11
    相关资源
    最近更新 更多