知乎排版优化

知乎排版优化!

目前为 2017-06-19 提交的版本。查看 最新版本

// ==UserScript==
// @name         知乎排版优化
// @namespace    https://www.zhihu.com/
// @version      1.4
// @description  知乎排版优化!
// @author       chenglinz <[email protected]>
// @match        https://www.zhihu.com/question/*
// @match        https://www.zhihu.com/people/*
// @match        https://www.zhihu.com/topic/*
// @match        https://www.zhihu.com/search?*
// @match        https://www.zhihu.com
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    var path = location.pathname.slice(0);
    (function (){
        if (path == '/') {
            var re = document.querySelector('.TopstorySideBar');
            re.remove();
            var inner = document.querySelector('.Topstory-mainColumn');
            inner.style.marginLeft = '150px';
            inner.style.marginRight = '150px';
        }
    })();
    (function (){
        if (path.match(/\/question\/\d+/g)) {
            var re = document.querySelector('.Question-sideColumn');
            re.remove();
            var inner = document.querySelector('.Question-mainColumn');
            inner.style.marginLeft = '155px';
        }
    })();
    (function (){
        if (path.match(/\/topic\/.*/g)) {
            // 知乎老版本中间居中.
            var inner = document.querySelector('.zu-main-content-inner');
            inner.style.marginLeft = '140px';
            inner.style.marginRight = '150px';
            var backtotop = document.querySelector('.zh-backtotop');
            backtotop.style.marginLeft = '350px';
            // 修改侧边栏宽度以适应居中
            var rightInner = document.querySelector('.zu-main-sidebar');
            rightInner.className='zu-main-sidebar';
            rightInner.style.width = '120px';
            rightInner.style.marginLeft = '-130px';
        }
    })();
    (function (){
        if (path.match(/\/people\/.*/g)) {
            var right = document.querySelector('.Profile-sideColumn');
            right.style.visibility = "hidden";
            var inner = document.querySelector('.Profile-mainColumn');
            inner.style.marginLeft = '155px';
        }
    })();
    // 只应用到主页,问题页,话题页,搜索页
    if (path.match(/\/search?.*/g)) {
        var re = document.querySelector('.zu-main-sidebar');
        re.style.visibility = "hidden";
        var inner = document.querySelector('.zu-main-content-inner');
        inner.style.marginLeft = '150px';
        inner.style.marginRight = '150px';
        var backtotop = document.querySelector('.zh-backtotop');
        backtotop.style.marginLeft = '350px';
    }
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址