Greasy Fork

来自缓存

Greasy Fork is available in English.

知乎移动端修复

知乎移动端修复:阻止跳转,自动展开

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         知乎移动端修复
// @version      1.0.2
// @description  知乎移动端修复:阻止跳转,自动展开
// @author       Allan Chain
// @homepage     https://github.com/AllanChain/zhihu-mobile
// @namespace    https://github.com/AllanChain/
// @icon         https://static.zhihu.com/heifetz/favicon.ico
// @include      https://www.zhihu.com/*
// @include      https://zhuanlan.zhihu.com/*
// @grant        GM_addStyle
// @run-at       document-start
// ==/UserScript==
// src/style.css
var style_default = ".DownloadGuide {\n  display: none;\n}\n.OpenInAppButton {\n  display: none;\n}\n.MobileAppHeader-downloadLink {\n  display: none;\n}\n.ModalWrap {\n  display: none;\n}\nhtml, body.ModalWrap-body {\n  overflow: auto !important;\n}\n.ContentItem-expandButton {\n  display: none;\n}\n.RichContent-inner {\n  max-height: unset !important;\n}\n";

// src/index.js
function expandRichContent(node) {
  node.classList.remove("is-collapsed");
}
function expandRichContentRecursive(node) {
  node.querySelectorAll(".RichContent.is-collapsed").forEach(expandRichContent);
}
console.log("\u77E5\u4E4E\u79FB\u52A8\u7AEF\u4FEE\u590D\u6B63\u5728\u8FD0\u884C");
GM_addStyle(style_default);
var observer = new MutationObserver((mutations) => {
  for (const m of mutations) {
    if (m.target.classList.contains("RichContent") && m.target.classList.contains("is-collapsed")) {
      expandRichContent(m.target);
    } else {
      for (const node in m.addedNodes) {
        if (node.nodeType === Node.ELEMENT_NODE && node.classList.contains("RichContent")) {
          expandRichContent(node);
        }
      }
    }
  }
});
window.addEventListener("load", function(event) {
  event.stopImmediatePropagation();
  expandRichContentRecursive(document);
  observer.observe(document.documentElement, {
    childList: true,
    subtree: true
  });
});
document.addEventListener("click", (event) => {
  if (event.target.tagName !== "BUTTON") {
    event.stopImmediatePropagation();
  }
}, false);