AdBlock 阻止 MathJax 和 AddThis

AdBlock blocks MathJax and AddThis

启用 AdBlock 后出现以下错误:

  1. 添加:Uncaught Error: Must pass a string which will eval to a globally accessible object where callbacks will be stored

  2. MathJax: 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' * 'unsafe-inline'".

禁用 AdBlock 后,一切正常。

这个问题是几周前出现的。

即使启用 AdBlock,在使用 MathJax 的网站上一切正常:https://www.mathjax.org and https://math.stackexchange.com/

可能发生了一些变化,我需要适当地更改代码。怎么样?

提前致谢。

这两个错误都指的是同一个内容安全策略 (CSP) 问题,即不安全的 eval() 调用是不允许的。 AdBlock 和 Adblock Plus 等广告拦截器最近开始使用 CSP 来解决传统技术无法解决的问题(参见 Adblock Plus filter options)。

我只能在 emathhelp.net 上复制它。在那里我找到了过滤器 ||emathhelp.net^$csp=script-src 'self' * 'unsafe-inline' 对此负责,它被添加到 EasyList 广告拦截列表 on May 15。在 Adblock Plus 中,您可以按照以下步骤找到此类过滤器:

  1. 右键单击页面上的任意位置
  2. Select "Inspect" 在上下文菜单中
  3. 切换到打开的 window 中的 "Adblock Plus" 选项卡
  4. 重新加载页面以填充选项卡中的列表
  5. 找到类型为 "CSP"
  6. 的请求旁边的过滤器

您可以联系 EasyList (GitHub, forum, website) 了解他们添加特定过滤器的原因。他们还应该能够帮助您恢复任何损坏的功能。