D0n9X1n / hexo-blog-encrypt

Yet, just another hexo plugin for security.
https://www.npmjs.com/package/hexo-blog-encrypt
MIT License
971 stars 101 forks source link

疑问? #100

Closed jerryc127 closed 4 years ago

jerryc127 commented 4 years ago

Issue

Expected Behavior

Actual Behavior

Steps to Reproduce the Problem

  1. _
  2. _
  3. _

Specifications

(The version of the project, operating system, hardware etc.)

<% if (post.encrypt == true) { %>
        <%- toc(post.origin) %>
      <% } else { %>
        <%- toc(post.content) %>
      <% } %>

这对代码的意义在哪? hexo s 发现 post.origin 还是 post.content 都会生成完整的toc 那这个判断的意义何在?

看起来好像只是toc-div的display: none 有作用。 但是代码限制死了只有用 toc-div的才会变成display = inline 对其他主题不太友好

D0n9X1n commented 4 years ago

不判断的话,hexo 会对加密后的文章生成 toc,也就是一堆无意义的摘要。

至于指定 div, display:none 是因为需要在未解密之前隐藏。指定 id 是因为无法预先知道其他主题的 div id。

你有更好的解决方案吗?

xiazeyu commented 4 years ago

https://greasyfork.org/scripts/28721-mutations/code/mutations.js?version=666427 康康这是什么原理

xiazeyu commented 4 years ago

不判断的话,hexo 会对加密后的文章生成 toc,也就是一堆无意义的摘要。

至于指定 div, display:none 是因为需要在未解密之前隐藏。指定 id 是因为无法预先知道其他主题的 div id。

你有更好的解决方案吗?

问题在于什么时候把内容加密 如果加密早了会导致Hexo提取不到TOC 加密晚了会导致一堆searchdb之类的插件把原文爬了好多好多遍...只要搜索框一搜索就能知道原文了

Hexo这方面做的比较垃圾

或许可以自己找个Markdown解析器写个TOC或者只能针对主题适配了(主题的渲染是在after_render之前的)

D0n9X1n commented 4 years ago

hexo 的钩子实在是太少了,也没有优先级概念,如果能在 hexo 上实现优先级的钩子队列就好办了。然后让加密插件强制在最后执行。

那个 js 好像在以 200ms 间隔不停的检查 dom 树。。。