知乎桌面版适配移动端

在你的手机上使用全功能的知乎桌面网页版。

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name        Zhihu Desktop on Mobile
// @name:zh-CN  知乎桌面版适配移动端
// @description Use full-featured desktop web zhihu on your phone.
// @description:zh-CN 在你的手机上使用全功能的知乎桌面网页版。
// @namespace   https://greasyfork.org/users/197529
// @version     0.1.4
// @author      kkocdko
// @license     Unlicense
// @match       *://*.zhihu.com/*
// @run-at      document-start
// ==/UserScript==

const afterEnter = (f, condition = () => document.documentElement) => {
  if (condition()) return f();
  const observer = new MutationObserver(() => {
    if (!condition()) return;
    observer.disconnect();
    f();
  });
  observer.observe(document, { childList: true, subtree: true });
};

const css = ([s]) => {
  const el = document.createElement("style");
  el.textContent = s.replace(/;/g, "!important;");
  afterEnter(() => {
    document.documentElement.appendChild(el);
  });
};

css`
  .ContentItem-title,
  .QuestionHeader-title {
    font-weight: normal;
    margin: 0;
  }
  .OpenInAppButton,
  .PlaceHolder.List-item {
    display: none;
  }
  @media (orientation: portrait) {
    header.AppHeader > * {
      min-width: 1280px;
    }
    header.AppHeader,
    .Topstory-container,
    .Topstory-mainColumn,
    .Question-main,
    .Question-mainColumn,
    .Search-container,
    .SearchMain,
    .Profile-main,
    .Profile-mainColumn,
    .TopicMetaCard,
    #TopicMain {
      overflow: auto;
      width: 100vw;
      min-width: 100vw;
      padding: 0;
      margin: 0;
      margin-top: -10px;
    }
    .Question-mainColumn + *,
    .Topstory-mainColumn + *,
    .ContentItem-actions > :not(:first-child) svg {
      display: none;
    }
    .Search-container .List-item,
    .Question-mainColumn .List-item,
    .Profile-mainColumn .List-item,
    .Topstory-mainColumn .TopstoryItem,
    .QuestionAnswer-content,
    .TopicFeedList .List-item {
      padding: 4px 4px 8px;
    }
    .ContentItem-actions {
      left: 0;
      padding: 4px 0 0 0;
      margin: 0;
      overflow: auto;
      overflow: overlay;
      overflow-y: hidden;
    }
    .ContentItem-actions > * {
      margin: 0 8px 0 0;
    }
    .ContentItem-actions.is-fixed {
      width: 100vw;
      padding: 0;
    }
    .Modal-content {
      max-width: 100vw;
    }
    .TopicMetaCard-wikiDescription {
      height: auto;
    }
    .Topic-bar {
      min-width: 520px;
    }
  }
`;