我正在考虑使用HTML5数据属性来简化我的应用程序的第三方脚本.所以,考虑两种情况:
<div>Sticker</div>.<div data-id="{{id}}" data-category="{{category-id}}">Sticker</div>.第二种情况(attrs的存在)可能会影响DOM /渲染性能,不是吗?如果是这样,多少钱?
为了澄清,我不打算单独使用数据属性,只是将它们暴露给第三方脚本或浏览器插件.考虑dotjs左右.使用数据属性,可以非常轻松地抓取/抓取页面.
很多网页似乎都使用/密钥进行搜索.我想禁用它,因为我想用100%的时间/在FireFox页面中搜索.有没有办法可以用GreaseMonkey或dotjs覆盖这种行为?
最好的公开示例是https://www.github.com/,也是https://wiki.jenkins-ci.org/display/JENKINS/Issue+Tracking
GitHub维基页面不再支持MathJax.似乎dotjs Chrome扩展可能是在这些页面上启用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);
})();
Run Code Online (Sandbox Code Playgroud)
但是,这不起作用,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
Run Code Online (Sandbox Code Playgroud)
什么是正确的JavaScript?