知乎去广告展开所有回答

去除知乎广告,自动展开所有回答

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         知乎去广告展开所有回答
// @namespace    https://www.zhihu.com/
// @version      1.0
// @description  去除知乎广告,自动展开所有回答
// @author       老胡
// @match        https://www.zhihu.com
// @match        https://www.zhihu.com/question/*
// @require      http://cdn.bootcss.com/jquery/1.8.3/jquery.min.js
// @run-at       document-end
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    clearAdvert();

    if(document.URL.indexOf("https://www.zhihu.com/question/") != -1) {
        autoExpandQuestionInfo();
    }

    //自动展开问题全部信息,同时展示所有回答
    function autoExpandQuestionInfo() {
        $('.Button.QuestionRichText-more.Button--plain').click();
        var moreAnswers = $('.QuestionMainAction');
        if(moreAnswers.length > 0) {
            moreAnswers[0].click();
        }
    }

    //去除首页广告
    function clearAdvert() {
        $('.Card.Banner').remove();
    }
})();