Anonymous Zhihu

我只想专心看答案,不想知道你是谁。

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Anonymous Zhihu
// @namespace    http://tampermonkey.net/
// @version      0.3
// @description  我只想专心看答案,不想知道你是谁。
// @author       You
// @match        https://www.zhihu.com/*
// @grant        none
// @require  https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js
// @require https://greasyfork.org/scripts/31940-waitforkeyelements/code/waitForKeyElements.js?version=209282
// ==/UserScript==

(function() {
    'use strict';

    // TODO:
    // 去掉鼠标悬浮时用户信息的加载

    // Your code here...
    var hiddenClassNames = [
        // index page
        'Voters',
        'ContentItem-actions',
        'Question-sideColumn',
        'GlobalSideBar-categoryList',

        // feed page
        'author-info',
        'zm-side-section-inner',
        'zm-item-answer-author-info',
        'zm-item-link-avatar',
        'zm-item-vote-info',
    ];

    var mentionClassNames = [
        'member_mention',
    ];

    var anonymousAvatar = 'https://pic1.zhimg.com/aadd7b895_xs.jpg';

    waitForKeyElements('.AuthorInfo-avatar', function(elem){
        elem.attr('src', anonymousAvatar,);
        elem.attr('srcset', anonymousAvatar);
    });

    waitForKeyElements('.AuthorInfo-head', function(elem) {
        elem.text('小明');
    });

    waitForKeyElements('.AuthorInfo-detail', function(elem) {
        elem.empty();
    });

    waitForKeyElements('.UserLink-link', function(elem) {
        var text = elem.text();
        elem.attr('href', '#');
        if(text[0] == '@') {
            elem.text('@小明');
            elem.attr('href', '#');
        }
    });

    hiddenClassNames.forEach(function(name) {
        waitForKeyElements('.'+name, function(elem) {
            elem.css('display', 'none');
        });
    });

    mentionClassNames.forEach(function(name) {
        waitForKeyElements('.'+name, function(elem) {
            elem.text('@小明');
            elem.attr('href', '#');
        });
    });
})();