• 首页
  • 搜索
  • 夜间模式
    ©2012-2025  Feng's Blog Theme by OneBlog
    搜索
    标签
    # 随笔 # 维修 # Wordpress # 阿里云 # 服务器 # typecho # Ghost # iphone # 网站 # word
  • 首页>
  • IT网络>
  • 正文
  • 巧用七牛使多说完美兼容 Https

    2016年11月27日 79 阅读 0 评论 2584 字

    之前写过一篇文章“让Typecho中的多说头像支持HTTPS",头像是可以支持Https了,但里面的表情却不行,这不又看到好文说可以完美兼容Https,赶紧照样画葫芦用起来呗:
    1、设置七牛,将镜像源设置为https://yourdomain.com/proxy/即可。
    2、修改 Embed.js,首先从 https://static.duoshuo.com/embed.js 下载然后格式化。
    3、修改头像,位于 580 行附近,搜索 avatarUrl: function(e) { 直达。

        if (document.location.protocol == "https:") {
        if (e.avatar_url) {
            var matched;
            if (matched = e.avatar_url.match(/^([^\/]*(\/\/q\.)*(\/\/app\.)*qlogo\.cn\/.+\/)\d{2}$/)) {
                e.avatar_url = matched[1] + "100"; // 50的图高分屏下会很模糊,改不改随你。不改的话整个 If 分支就不需要了。
                e.avatar_url = e.avatar_url.replace(/^http\:\/\//, "https://");
            } else if (matched = e.avatar_url.match(/^(.*avatar\.duoshuo\.com\/avatar\-)\d{2}(\/.+)$/)) {
                e.avatar_url = matched[1] + "100" + matched[2]; // 50的图高分屏下会很模糊,改不改随你。不改的话整个 If 分支就不需要了。
                e.avatar_url = e.avatar_url.replace(/^http\:\/\//, "https://");
            } else if (e.avatar_url.match(/^http:\/\/wx\.qlogo\.cn.*$/) || e.avatar_url.match(/^.*avatar\.duoshuo\.com.*$/)) {
                e.avatar_url = e.avatar_url.replace(/^http\:\/\//, "https://");
            } else if (matched = e.avatar_url.match(/^(.*qlogo\.cn\/.+\/)\d{2}$/)) {
                e.avatar_url = matched[1] + "100"; // 50的图高分屏下会很模糊,改不改随你。不改的话整个 If 分支就不需要了。
            }  else if (e.avatar_url.match(/^.*img\d+\.douban\.com.*$/)) {
                e.avatar_url = e.avatar_url.replace(/img\d+\.douban\.com/, "img2.doubanio.com");//豆瓣无需镜像
            }
            if (e.avatar_url.match(/^http:\/\/.+$/)) {
                e.avatar_url = "https://yours.qnssl.com/" + base64_encode(e.avatar_url);
                // 像大神们的那种反代大概就可以改成这样:
                // e.avatar_url = "https://yours.qnssl.com/" + e.avatar_url.replace(/^http\:\/\//, "");
                // 普通的地址:
                // e.avatar_url = "https://yourdomain.com/proxy?src=" + e.avatar_url;
            }
        } else {
            var matched = rt.data.default_avatar_url.match(/^(.*avatar\.duoshuo\.com\/avatar\-)\d{2}(\/.+)$/);
            if (matched != null) {
                rt.data.default_avatar_url = matched[1] + "100" + matched[2]; // 50的图高分屏下会很模糊,改不改随你。不改的话整个 If 分支就不需要了。
            }
        }
    }
    // 默认头像现在多说已经支持 Https, 因此不需要修改。
    return e.avatar_url || rt.data.default_avatar_url

    4、修改评论中的表情和图片,位于 740 行附近,搜索s.message直达。

            var matched;
    本文著作权归作者 [ Feng ] 享有,未经作者书面授权,禁止转载,封面图片来源于 [ 互联网 ] ,本文仅供个人学习、研究和欣赏使用。如有异议,请联系博主及时处理。
    网站
    — END —
    首页
    Copyright©2012-2025  All Rights Reserved.  Load:0.014 s
    Theme by OneBlog V3.6.3
    夜间模式

    开源不易,请尊重作者版权,保留基本的版权信息。