【问题标题】:Why does GitHub append a js to my jekyll site为什么 GitHub 会在我的 jekyll 网站上附加一个 js
【发布时间】:2015-07-29 10:23:24
【问题描述】:

我注意到 GitHub 附加了一个 似乎 的 js,当电子邮件地址带有字符串 /cdn-cgi/l/email-protection 时,它会删除指向电子邮件地址的链接。其他人有这个奇怪的问题,或者这真的来自 GitHub?

这是这个脚本的美化版本:

(function() {
    try {
        var s, a, i, j, r, c, l = document.getElementsByTagName("a"),
            t = document.createElement("textarea");
        for (i = 0; l.length - i; i++) {
            try {
                a = l[i].getAttribute("href");
                if (a && a.indexOf("/cdn-cgi/l/email-protection") > -1 && (a.length > 28)) {
                    s = '';
                    j = 27 + 1 + a.indexOf("/cdn-cgi/l/email-protection");
                    if (a.length > j) {
                        r = parseInt(a.substr(j, 2), 16);
                        for (j += 2; a.length > j && a.substr(j, 1) != 'X'; j += 2) {
                            c = parseInt(a.substr(j, 2), 16) ^ r;
                            s += String.fromCharCode(c);
                        }
                        j += 1;
                        s += a.substr(j, a.length - j);
                    }

                    t.innerHTML = s.replace(/</g, "&lt;").replace(/>/g, "&gt;");
                    l[i].setAttribute("href", "mailto:" + t.value);
                }
            } catch (e) {}
        }
    } catch (e) {}
})();

当我有一个像&lt;a href="mailto:/cdn-cgi/l/email-protection/email@foo.com"&gt;Contact&lt;/a&gt; 这样的链接时,它变成了&lt;a href="mailto:"&gt;Contact&lt;/a&gt;。否则,它不会做任何事情。不过,这让我很困扰,因为我还没有把那个脚本放在那里,而且我似乎没有收到任何关于 GH 附加脚本的警告。

【问题讨论】:

    标签: javascript github jekyll github-pages


    【解决方案1】:

    我刚收到来自 GitHub 支持的回复,原来是 CloudFlare 在开启Email Address Obfuscation 功能时添加了神秘脚本。

    相关设置在https://www.cloudflare.com/a/content-protection/&lt;&lt;domain.name&gt;&gt;ScrapeShield下,如果有人遇到类似问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-01-11
      • 2022-12-25
      • 1970-01-01
      • 2015-10-08
      • 1970-01-01
      • 2022-07-22
      • 1970-01-01
      相关资源
      最近更新 更多