diff --git a/README.md b/README.md index 9669def9..2f66edd7 100644 --- a/README.md +++ b/README.md @@ -69,6 +69,10 @@ Argon 使用 [GPL V3.0](https://github.com/solstice23/argon-theme/blob/master/LI # 更新日志 +## 20200824 v1.0.1 ++ 增加 "评论文字头像" 选项(为无头像评论者生成一个纯色文字头像) ++ Github 短代码新增 Mini 尺寸 + ## 20200823 v1.0.0 + 正式版 diff --git a/argontheme.js b/argontheme.js index 4887bc16..af4dc3c8 100644 --- a/argontheme.js +++ b/argontheme.js @@ -1160,6 +1160,25 @@ foldLongComments(); $(document).on("click" , ".show-full-comment" , function(){ $(this).parent().removeClass("comment-folded").addClass("comment-unfolded"); }); +/*评论文字头像*/ +document.addEventListener("error", function(e){ + let img = $(e.target); + if (!img.hasClass("avatar")){ + return; + } + if (!img.parent().hasClass("comment-item-avatar")){ + return; + } + let emailHash = img.attr("src").match(/([a-f\d]{32}|[A-F\d]{32})/)[0]; + let hash = 0; + for (i in emailHash){ + hash = (hash * 233 + emailHash.charCodeAt(i)) % 16; + } + console.log(hash); + let colors = ['#e25f50', '#f25e90', '#bc67cb', '#9672cf', '#7984ce', '#5c96fa', '#7bdeeb', '#45d0e2', '#48b7ad', '#52bc89', '#9ace5f', '#d4e34a', '#f9d715', '#fac400', '#ffaa00', '#ff8b61', '#c2c2c2', '#8ea3af', '#a1877d', '#a3a3a3', '#b0b6e3', '#b49cde', '#c2c2c2', '#7bdeeb', '#bcaaa4', '#aed77f']; + let text = $(".comment-name", img.parent().parent()).text().trim()[0]; + img.parent().html('
gravatar.loli.net/avatar/
, cdn.v2ex.com/gravatar/
, dn-qiniu-avatar.qbox.me/avatar/
gravatar.loli.net/avatar/
, cdn.v2ex.com/gravatar/
, dn-qiniu-avatar.qbox.me/avatar/