stripsAuthorScripts function

bool stripsAuthorScripts({
  1. bool ownPage = false,
  2. bool focus = false,
  3. bool restore = false,
  4. bool anchor = false,
  5. bool outline = false,
  6. bool section = false,
})

这一页要不要在注入脚本前摘掉作者的脚本(纯判定,供单测钉住)。

只对「别人的页面」摘:为定位 / 阅读位置而开脚本时,作者的 <script> 与内联 事件不能跟着跑。

ownPage 为 true 的是调用方自己生成的页面 —— 那份 html 里的脚本就是它自己的 桥脚本,跟着一起摘的话桥也没了,整页只剩静态内容。所以「开着脚本」不等于「该摘」: 判据是「我们要开脚本,且这页不是我们自己生成的」。

其余开关各自代表一种「需要我们注入脚本」的能力:定位搜索命中(focus)、记阅读 位置(restore / anchor)、章节清单(outline)、读到第几节(section)。 任一为 true 就视为要开脚本。

Implementation

bool stripsAuthorScripts({
  bool ownPage = false,
  bool focus = false,
  bool restore = false,
  bool anchor = false,
  bool outline = false,
  bool section = false,
}) => !ownPage && (focus || restore || anchor || outline || section);