Greasy Fork

来自缓存

Greasy Fork is available in English.

知乎右上角显示编辑时间

在内容右上角显示编辑时间

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name        知乎右上角显示编辑时间
// @name:zh-TW  知乎右上角顯示編輯時間
// @name:en     Show Editing Time at Top-right
// @namespace   http://greasyfork.icu/en/users/211578
// @description 在内容右上角显示编辑时间
// @description:zh-TW  在内容右上角顯示編輯時間
// @description:en  Move the editing time of posts to their top right corners.
// @version     1.0
// @match       https://*.zhihu.com/*
// @run-at      document-idle
// @inject-into auto
// @grant       GM_addStyle
// @author      twchen
// ==/UserScript==

if (typeof GM_addStyle == "undefined") {
  this.GM_addStyle = css => {
    const style = document.createElement("style");
    style.textContent = css;
    document.documentElement.appendChild(style);
    return style;
  };
}

const url = window.location.href;
if (url.includes("zhuanlan")) {
  const container = document.querySelector(".Post-RichTextContainer");
  const time = document.querySelector(".ContentItem-time");
  container.appendChild(time);
  GM_addStyle(`
    .Post-RichTextContainer {
      position: relative;
    }
    .ContentItem-time {
      position: absolute;
      top: -1rem;
      right: 0;
      margin: 0;
      padding: 0;
    }
  `);
} else if (url.includes("collection")) {
  GM_addStyle(`
    .answer-date-link {
      position: absolute;
      top: 0;
      right: 0;
    }
  `);
} else {
  GM_addStyle(`
    .RichContent {
      position: relative;
    }
    .ContentItem-time {
      position: absolute;
      top: -1.5rem;
      right: 0;
      margin: 0;
      padding: 0;
    }
  `);
}