优化移动端知乎网页

自动展开,去除app下载,去除打开app

As of 2020-10-21 10:36:48 UTC. See the latest version.

// ==UserScript==
// @name         优化移动端知乎网页
// @version      1.3
// @description  自动展开,去除app下载,去除打开app
// @author       Zruiry
// @match        https://www.zhihu.com/*
// @grant        none
// @namespace    Zruiry
// ==/UserScript==

(function() {

    // 知乎消除
    const ele = [
        // 头部
        '.MobileAppHeader-inner',
        // 底部悬浮的打开app
        '.OpenInAppButton',
        // 打开app查看更多评论
        '.CommentsForOia .Button',
        // 评论下方广告
        '.MBannerAd',
        // 相关推荐
        '.RelatedReadings',
        // 热门推荐
        '.HotQuestions'
    ];
    for (let e of ele) {
        document.querySelector('style').innerHTML += e + `{display: none !important;}`;
    }

    try {
        // 消除遮屏弹窗
        var obj = document.querySelector('.ModalWrap').children[0];
        obj.children[0].setAttribute('class', '');
        obj.children[1].setAttribute('class', 'ModalExp-content');
        obj.setAttribute('data-stop-scroll-propagation', false);
    } catch (e) {
        console.log(e);
    }

    try {
        // 自动展开
        var open = document.querySelector('.RichContent');
        open.setAttribute('class', 'RichContent RichContent--unescapable');
        open.removeChild(open.childNodes[1]);
        document.querySelector('.RichContent-inner').setAttribute('style', 'max-height: auto !important;');
        document.querySelector('.ContentItem-actions').setAttribute('class', 'ContentItem-actions RichContent-actions');
    } catch (e) {
        console.log(e);
    }

    try {
        // 开启页面滚动
        document.querySelector('body').setAttribute('class', 'Body--Mobile Body--Android');
        document.querySelector('body').setAttribute('style', 'overflow: auto');
    } catch (e) {
        console.log(e);
    }

})();