简化知乎页面

简化 | 美化知乎页面

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         简化知乎页面
// @namespace    http://tampermonkey.net/
// @version      0.4
// @description  简化 | 美化知乎页面
// @author       Lynn Speng
// @match        *://www.zhihu.com/*
// @grant        none
// ==/UserScript==


setInterval(() => {
    // 删除掺杂在回答里的广告
    let ads = document.getElementsByClassName("TopstoryItem--advertCard");
    if (ads.length > 0) {
        for (let i = 0; i < ads.length; ++i)
            ads[i].remove();
    }

    // 删除侧边栏广告
    let pcAds = document.getElementsByClassName("Pc-card");
    if (pcAds.length > 0) {
        for (let i = 0; i < pcAds.length; ++i)
            pcAds[i].remove();
    }

    // 删除视频推送
    let videos = document.getElementsByClassName("ZVideoItem");
    if (videos.length > 0) {
        for (let i = 0; i < videos.length; ++i)
            videos[i].parentNode.parentNode.remove();
    }
}, 100);


// 调整卡片样式
let style = document.createElement("style");
style.innerHTML = 
    'body { background-color: #274c5e }\
    .Avatar {border-radius: 50%;}\
    .Card, .ClubSliderList, .Footer, .HotItem, .HotList { margin: 20px; border-radius: 8px; }\
    .Question-sideColumn{display: none;}\
    .Question-mainColumn{width: 1000px;}\
    .QuestionInvitation{display: none;}\
    .css-1roounf{display: none;}\
    .css-neu31m{display: none;}\
    .css-1qefhqu{width: 80px;}\
    .UserAvatar{border-radius: 100%;}\
    .Profile-lightList {margin: 20px; background-color: white; border-radius: 8px; padding: 0 10px;}\
    .Profile-footerOperations {margin: 20px}'
document.head.appendChild(style);