Greasy Fork

Greasy Fork is available in English.

知乎问答页面重新排版

try to take over the world!

当前为 2016-07-25 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

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

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         知乎问答页面重新排版
// @namespace    https://www.zhihu.com/
// @version      0.1
// @description  try to take over the world!
// @author       You
// @match        https://www.zhihu.com/question*
// @match        https://www.zhihu.com
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    function getByClass(sClass){
        var aResult=[];
        var aEle=document.getElementsByTagName('*');
        /*正则模式*/
        var re=new RegExp("\\b" + sClass + "\\b","g");
        for(var i=0;i<aEle.length;i++){
            /*字符串search方法判断是否存在匹配*/
            if(aEle[i].className.search(re) != -1){
                aResult.push(aEle[i]);
            }
        }
        return aResult;
    }
    var re = getByClass('zu-main-sidebar');
    re[0].remove();
    var inner = getByClass('zu-main-content-inner');
    inner[0].style.marginLeft = '150px';
    inner[0].style.marginRight = '150px';
    var backtotop = getByClass('zh-backtotop');
    backtotop[0].style.marginLeft = '350px';
})();