Greasy Fork

自动展开全文

自动展开网站内容而无需点击。当前支持知乎,cdsn,B 站和 Youtube 的视频简介。如需支持更多内容,请至以下网址提交 https://meta.appinn.net/t/14383

目前为 2020-03-08 提交的版本。查看 最新版本

// ==UserScript==
// @name        自动展开全文
// @namespace   Show me all post.
// @match       *://www.zhihu.com/question/*
// @match       *://blog.csdn.net/*/article/details/*
// @match       *://www.bilibili.com/video/av*
// @match       *://www.youtube.com/watch?v=*
// @grant       GM_addStyle
// @version     0.0.2
// @author      稻米鼠
// @description 自动展开网站内容而无需点击。当前支持知乎,cdsn,B 站和 Youtube 的视频简介。如需支持更多内容,请至以下网址提交 https://meta.appinn.net/t/14383
// ==/UserScript==

const rules = [
  { // 知乎 - 移动端页面
    reg: /^http(s):\/\/(www\.)?zhihu\.com\/question\/\d+/,
    remove: ['.RichContent--unescapable.is-collapsed .ContentItem-rightButton'],
    content: ['.Body--Mobile .RichContent.is-collapsed .RichContent-inner'],
  },
  { // CSDN - PC & 移动端页面
    reg: /^http(s):\/\/blog\.csdn\.net\/[^/]+\/article\/details\/\d+/,
    remove: ['div.hide-article-box', '.readall_box'],
    content: ['#article_content', '#article .article_content'],
  },
  { // B 站视频简介
    reg: /^http(s):\/\/(www\.)?bilibili\.com\/video\/av\d+/,
    remove: ['.video-desc .btn'],
    content: ['.video-desc .info'],
  },
  { // B 站视频简介
    reg: /^http(s):\/\/(www\.)?youtube\.com\/watch\?v=\w+/,
    remove: ['paper-button.ytd-expander'],
    content: ['#content.ytd-expander'],
  },
]

for(const rule of rules){
  if(rule.reg.test(window.location.href)){
    const removeEls = rule.remove.join(',\n')
    const contentEls = rule.content.join(',\n')
    GM_addStyle(`
      `+removeEls+` {
        display: none !important;
      }
      `+contentEls+` {
        height: auto !important;
        max-height: none !important;
      }
    `)
  }
}