知乎Enhance

关闭登录提示、跳转链接直接跳转、缩小顶部导航栏范围

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         知乎Enhance
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  关闭登录提示、跳转链接直接跳转、缩小顶部导航栏范围
// @author       jiang
// @match        https://*.zhihu.com/*
// @icon         https://static.zhihu.com/heifetz/favicon.ico
// @require      https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.min.js
// @license		 GPL-3.0
// @grant        GM_addStyle
// ==/UserScript==
// 1. 关闭登录提示
// 2. 跳转链接直接跳转
// 3. 缩小顶部导航栏范围(解决屏幕过小时导航栏溢出的问题)
/* global $ */
function runV0_0_1() {
  closeLoginModal();
  var ci = setInterval(() => {
    closeLoginModal();
  }, 200);
  setTimeout(() => {
    clearInterval(ci);
  }, 3e3);
  function closeLoginModal() {
    var btn = document.querySelector("Button.Modal-closeButton");
    if (btn) {
      btn.click();
      clearInterval(ci);
    }
  }
  continueVisit();
  var vi = setInterval(() => {
    continueVisit();
  }, 200);
  setTimeout(() => {
    clearInterval(vi);
  }, 3e3);
  function continueVisit() {
    var a = document.querySelector("a.button");
    if (a && a.innerText === "继续访问") {
      a.click();
      clearInterval(vi);
    }
  }
}
async function navModify() {
  const style = `
@media screen and (max-width:1100px){
    .zhihu-enhance-app-header{
        margin-left: 0px
    }
}`;
  GM_addStyle(style);
  const header = $(".AppHeader>div");
  console.log("================", header);
  header.css("width", "1000px");
  header.addClass("zhihu-enhance-app-header");
}
(async function() {
  runV0_0_1();
  navModify();
})();