ZhihuHelper

A real "helper" for Zhihu

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         ZhihuHelper
// @namespace    http://tampermonkey.net/
// @version      0.6
// @description  A real "helper" for Zhihu
// @author       You
// @match        https://*.zhihu.com/*
// @grant        none
// @require http://code.jquery.com/jquery-3.3.1.min.js
// ==/UserScript==

function AddPersonalStyle() {
    'use strict';
    //Expend the read div width

    var myStyle = document.createElement("style");
    myStyle.setAttribute("id","myStyle");
    myStyle.setAttribute("type","text/css");
    myStyle.appendChild(document.createTextNode(""));
    document.head.appendChild(myStyle);
    myStyle.sheet.insertRule('.GlobalSideBar{display:none}',0);
    //Hide images
    myStyle.sheet.insertRule('figure{display:none}',1);
    myStyle.sheet.insertRule('.ContentItem-title{font-size:15px;font-weight:400}',2);
    myStyle.sheet.insertRule('.RichContent-cover{display:none}',3);
    myStyle.sheet.insertRule('.ArticleItem-image{display:none}',3);
    //Buttons at the article bottom
    myStyle.sheet.insertRule('.Button--withIcon{display:none}',4);
    myStyle.sheet.insertRule('.Sticky div a svg{display:none}',5);
    myStyle.sheet.insertRule('.TopstoryItem--advertCard{display:none}',6);
    myStyle.sheet.insertRule('.btnFloatCorner{position:fixed;margin:20px;float:right;top:50px}',7);
    myStyle.sheet.insertRule('.VoteButton {background: #FFF; color: #000;}',8);
    myStyle.sheet.insertRule('.TopstoryItem--advertCard{display:none}',9);
    myStyle.sheet.insertRule('svg{display:none}',10);
    myStyle.sheet.insertRule('.ContentItem-more{float:right}', 11);
    myStyle.sheet.insertRule('.Topstory-container{width:70%}',12);
    myStyle.sheet.insertRule('.Topstory-mainColumn{width:100%}',12);
    myStyle.sheet.insertRule('.stackoverflow{width:10%;float:left}',12);
}
AddPersonalStyle();
    
function AddControlBtn(){
    var ctlBtn = document.createElement("button");
    ctlBtn.setAttribute("id", "mainCtlBtn");
    ctlBtn.setAttribute("class", "btnFloatCorner");
    var btnImg = document.createElement("img");
    btnImg.setAttribute("src", "https://www.stackoverflowbusiness.com/hubfs/B2B-SO/images/SO_Talent.svg");
    btnImg.setAttribute("class", "stackoverflow");
    ctlBtn.appendChild(btnImg);
    document.body.appendChild(ctlBtn);
}
AddControlBtn();
    
/*******************************Below is functions********************************** */
//Control the img display
$("#mainCtlBtn").on("click", function (){
    var styleElement = document.getElementById("myStyle");
    if(styleElement.sheet.cssRules[1].style.display == "none"){
        styleElement.sheet.cssRules[1].style.display = "block";
    }else{
        styleElement.sheet.cssRules[1].style.display = "none";
    }
});