简体   繁体   English

如何在GitHub维基页面上插入javascript以启用MathJax?

[英]How to insert javascript to enable MathJax on GitHub wiki pages?

The GitHub wiki pages no longer support MathJax . GitHub维基页面不再支持MathJax It seems like the dotjs Chrome extension might be a way to enable MathJax on these pages. 似乎dotjs Chrome扩展可能是在这些页面上启用MathJax的一种方式。

Here is my first attempt at creating javascript that would execute on github.com pages, and insert the right code needed to enable 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);
 })();

This doesn't work, however, and the following error appears in the Chrome JavaScript Console: 但是,这不起作用,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

What is the correct JavaScript? 什么是正确的JavaScript?

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM