├── LICENSE ├── README.md ├── screenshot ├── 20200911160558-min.png ├── 20200911160603-min.png ├── 20200911160615-min.png └── 20200911160630-min.png └── simpleZhiHu.js /LICENSE: -------------------------------------------------------------------------------- 1 | BSD 3-Clause License 2 | 3 | Copyright (c) 2021, Chao 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | 1. Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | 2. Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | 3. Neither the name of the copyright holder nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 极简知乎 2 | 3 | [GitHub 项目地址](https://github.com/hceasy/simpleZhiHu/) 4 | 5 | ### 作用 6 | 7 | 优化知乎界面 8 | 9 | 免登录 10 | 11 | 去广告 12 | 13 | 黑名单功能 14 | 15 | 16 | 知乎账号已注销,故仅匹配未登录界面. 17 | 18 | ### 使用方法 19 | 20 | 1.安装 Greasemonkey 或 Tampermonkey 21 | 22 | - Firefox 23 | 24 | [Greasemonkey](https://addons.mozilla.org/firefox/addon/greasemonkey/) 25 | 26 | [Tampermonkey](https://addons.mozilla.org/firefox/addon/tampermonkey/) 27 | 28 | - Chrome 29 | 30 | [Tampermonkey](https://chrome.google.com/webstore/detail/tampermonkey/dhdgffkkebhmkfjojejmpbldmpobfkfo) 31 | 32 | 2.下载脚本安装 33 | 34 | 点击[simpleZhiHu](https://greasyfork.org/zh-CN/scripts/37823-%E6%9E%81%E7%AE%80%E7%9F%A5%E4%B9%8E)下载, 35 | 36 | 3.浏览知乎某个问题列表,页面加载完便会生效. 37 | 38 | 4.鼠标放在右上角刘看山图标上,弹出设置菜单 39 | 40 | ### 效果 41 | 42 | ![](https://github.com/hceasy/simpleZhiHu/blob/master/screenshot/20200911160558-min.png) 43 | 44 | ![](https://github.com/hceasy/simpleZhiHu/blob/master/screenshot/20200911160603-min.png) 45 | 46 | ![](https://github.com/hceasy/simpleZhiHu/blob/master/screenshot/20200911160615-min.png) 47 | 48 | ![](https://github.com/hceasy/simpleZhiHu/blob/master/screenshot/20200911160630-min.png) 49 | 50 | ### 备注 51 | 52 | ### 已适配 53 | 54 | - \*://www.zhihu.com/question/\* 问题页面 55 | 56 | - \*://www.zhihu.com/search\* 搜索页面 57 | 58 | - \*://www.zhihu.com/signin\* 登录页面 59 | 60 | - \*://www.zhihu.com/hot 热榜 61 | 62 | - \*://www.zhihu.com/follow 关注 63 | 64 | - \*://www.zhihu.com/ 个人首页 65 | 66 | - \*://zhuanlan.zhihu.com/ 知乎专栏 67 | 68 | ### 0.1.34 更新 69 | 70 | - 屏蔽盐选 71 | 72 | ### 0.1.33 更新 73 | 74 | - 修复黑名单功能 75 | 76 | ### 0.1.32 更新 77 | 78 | - 去掉两个登录弹窗提示 79 | 80 | ### 0.1.31 更新 81 | 82 | - 评论弹窗修复 83 | 84 | - 问题描述修复 85 | 86 | ### 0.1.29 更新 87 | 88 | - 页面宽度可自定义 89 | 90 | ### 0.1.28 更新 91 | 92 | - 修复黑名单功能 93 | 94 | ### 0.1.27 更新 95 | 96 | - 添加www2.zhihu.com支持 97 | 98 | ### 0.1.26 更新 99 | 100 | - 修复界面不能点击的问题. 101 | 102 | 103 | ### 0.1.25 更新 104 | 105 | - 修复因知乎更新,不登录不能滚动页面的问题. 106 | 107 | 108 | ### 0.1.24 更新 109 | 110 | - 搜索结果直接进入时错位优化. 111 | 112 | 113 | ### 0.1.23 更新 114 | 115 | - 展开评论优化. 116 | 117 | 118 | ### 0.1.22 更新 119 | 120 | - 问题标题优化. 121 | 122 | 123 | ### 0.1.21 更新 124 | 125 | - 夹缝广告去除. 126 | 127 | 128 | ### 0.1.20 更新 129 | 130 | - 知乎专栏页面简单修改. 131 | 132 | ### 0.1.19 更新 133 | 134 | - 添加了一个动画,免得找不到设置位置.保存一次配置后动画清除. 135 | 136 | ### 0.1.18 更新 137 | 138 | - 添加设置菜单(右上角) 139 | - 添加黑名单功能 140 | - 隐藏推荐商品链接 141 | 142 | ### 0.1.17 更新 143 | 144 | - 隐藏问题页面登录提示 145 | - 问题不再铺满全屏 146 | 147 | ### 0.1.16 更新 148 | 149 | - 加入未登录直接跳转到热榜按钮 150 | 151 | ### 0.1.15 更新 152 | 153 | - mac 中 `ctrl`+`alt`+`shift` 会导致字母变符号,去掉 `alt` 兼容 mac 154 | - 隐藏标题与隐藏提问改为快捷键 `ctrl`+`shift`+`T`/`ctrl`+`shift`+`Q` 155 | 156 | ### 0.1.14 更新 157 | 158 | - 解决 Greasemonkey 中脚本不运行的问题 159 | - 隐藏标题与隐藏提问改为快捷键 `ctrl`+`alt`+`shift`+`T`/`ctrl`+`alt`+`shift`+`Q` 160 | 161 | ### 19.6.9 更新 162 | 163 | - 适配了首页的关注,热榜 164 | 165 | ### 12.13 更新 166 | 167 | - 优化了切换标题与问题显示功能 168 | 169 | ### 12.06 更新 170 | 171 | - 加入切换标题与问题显示功能 172 | 173 | ### 9.13 更新 174 | 175 | - 适配搜索结果页面 176 | 177 | ### 7.27 更新 178 | 179 | - 图片最大 300 像素 180 | - 去掉问题顶部提示框 181 | -------------------------------------------------------------------------------- /screenshot/20200911160558-min.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hceasy/simpleZhiHu/2eb201e736826ff3ba5d507c3a775ab2a906ab66/screenshot/20200911160558-min.png -------------------------------------------------------------------------------- /screenshot/20200911160603-min.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hceasy/simpleZhiHu/2eb201e736826ff3ba5d507c3a775ab2a906ab66/screenshot/20200911160603-min.png -------------------------------------------------------------------------------- /screenshot/20200911160615-min.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hceasy/simpleZhiHu/2eb201e736826ff3ba5d507c3a775ab2a906ab66/screenshot/20200911160615-min.png -------------------------------------------------------------------------------- /screenshot/20200911160630-min.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hceasy/simpleZhiHu/2eb201e736826ff3ba5d507c3a775ab2a906ab66/screenshot/20200911160630-min.png -------------------------------------------------------------------------------- /simpleZhiHu.js: -------------------------------------------------------------------------------- 1 | // ==UserScript== 2 | // @name 极简知乎 3 | // @version 0.1.34 4 | // @author hceasy 5 | // @namespace https://hceasy.com 6 | // @supportURL https://github.com/hceasy/simpleZhiHu/issues 7 | // @description 优化阅读界面,免登录,广告去除,黑名单功能. 8 | // @match *://www.zhihu.com/question/* 9 | // @match *://www2.zhihu.com/question/* 10 | // @match *://www.zhihu.com/search* 11 | // @match *://www.zhihu.com/hot 12 | // @match *://www.zhihu.com/follow 13 | // @match *://www.zhihu.com/ 14 | // @match *://zhuanlan.zhihu.com/* 15 | // @match *://www.zhihu.com/signin* 16 | // @run-at document-end 17 | // ==/UserScript== 18 | ; (function () { 19 | 'use strict' 20 | // 设置菜单 21 | const menuHTML = `
刘看山

显示提问标题栏

浏览器标题替换

页面宽度(694px/80%)

黑名单列表:

` 22 | const menuCss = `.extMenu {position: fixed;top: 10px;right: 10px;width: 15px;height: 19px;font-size: 12px;overflow: hidden;}.extMenu:hover {width: auto;height: auto;border: 1px solid #000;padding:10px;}.extMenu:hover img {display: none;}` 23 | const blinkLiu = `.extMenu{animation:jumpLiu 5s infinite}@keyframes jumpLiu{0%{right:10px;background-color:#264653}20%{right:20px;background-color:#2a9d8f}40%{right:30px;background-color:#e9c46a}60%{right:10px;background-color:#f4a261}80%{right:20px;background-color:#e76f51}100%{right:10px;background-color:#264653}}` 24 | 25 | // 区分搜索问答页面 26 | const pathName = window.location.pathname 27 | const hostName = window.location.hostname 28 | let pageType 29 | if (pathName.indexOf('question') >= 0) { 30 | pageType = 'question' 31 | } else if (pathName.indexOf('search') >= 0) { 32 | pageType = 'search' 33 | } else if (pathName.indexOf('hot') >= 0 || pathName.indexOf('follow') >= 0 || window.location.href === "https://www.zhihu.com/") { 34 | pageType = 'hot' 35 | } else if (pathName.indexOf('signin') >= 0) { 36 | pageType = 'signin' 37 | } else if (hostName === "zhuanlan.zhihu.com") { 38 | pageType = 'zhuanlan' 39 | } 40 | 41 | // 用GitHub的图标替换 42 | const fake_title = 'GitHub' 43 | // icon也改了 44 | const fake_icon = 'https://github.githubassets.com/favicon.ico' 45 | let link = 46 | document.querySelector("link[rel*='icon']") || 47 | document.createElement('link') 48 | window.onload = function () { 49 | const sConfig = window.localStorage 50 | if (sConfig.fakeTitle === undefined || sConfig.showQuestion === undefined || sConfig.blackList === undefined || sConfig.pageWidth === undefined) { 51 | sConfig.fakeTitle = 'true' 52 | sConfig.showQuestion = 'true' 53 | sConfig.blackList = '' 54 | sConfig.pageWidth = '694px' 55 | } 56 | // 不登陆不让滚动 57 | let modelsNum = 0 58 | let fixTimer = setInterval(() => { 59 | const mainHtml = document.getElementsByTagName('html')[0] 60 | if (mainHtml.style.overflow === 'hidden') { 61 | mainHtml.style.overflow = '' 62 | } 63 | }, 200); 64 | // 添加菜单 65 | let cssFix = document.createElement('style') 66 | cssFix.innerHTML += menuCss 67 | if (typeof (sConfig.blinkLiu) === 'undefined') { 68 | cssFix.innerHTML += blinkLiu 69 | } 70 | document.getElementsByTagName('head')[0].appendChild(cssFix) 71 | let htmlFix = document.createElement('div') 72 | htmlFix.innerHTML += menuHTML 73 | document.body.appendChild(htmlFix) 74 | 75 | // 绑定操作 76 | document.getElementById('showFakeTitle').checked = JSON.parse(sConfig.fakeTitle) 77 | document.getElementById('showQuestion').checked = JSON.parse(sConfig.showQuestion) 78 | document.getElementById('blackList').value = sConfig.blackList 79 | document.getElementById('pageWidth').value = sConfig.pageWidth 80 | document.getElementById('saveConfig').addEventListener('click', function () { 81 | sConfig.fakeTitle = document.getElementById('showFakeTitle').checked 82 | sConfig.showQuestion = document.getElementById('showQuestion').checked 83 | sConfig.blackList = document.getElementById('blackList').value.split(',') 84 | sConfig.pageWidth = document.getElementById('pageWidth').value 85 | sConfig.blinkLiu = false 86 | window.location.reload() 87 | }) 88 | 89 | // 改下标题 90 | if (sConfig.fakeTitle === 'true') { 91 | window.document.title = fake_title 92 | link.type = 'image/x-icon' 93 | link.rel = 'shortcut icon' 94 | link.href = fake_icon 95 | document.getElementsByTagName('head')[0].appendChild(link) 96 | } 97 | switch (pageType) { 98 | case 'question': 99 | fixQuestionPage() 100 | fixPageWidth() 101 | break 102 | case 'search': 103 | fixSearchPage() 104 | break 105 | case 'hot': 106 | fixHomePage() 107 | break 108 | case 'signin': 109 | addHotList() 110 | break 111 | case 'zhuanlan': 112 | fixZhuanLan() 113 | break 114 | } 115 | hideAuthor() 116 | } 117 | window.onscroll = function () { 118 | hideAuthor() 119 | } 120 | function addHotList () { 121 | let signButton = document.querySelector('.SignFlow-submitButton') 122 | if (signButton) { 123 | let hotButton = signButton.cloneNode(false) 124 | let parent = signButton.parentNode; 125 | parent.appendChild(hotButton) 126 | hotButton.innerHTML = '不想登录,去热榜转转' 127 | hotButton.onclick = function () { 128 | location.href = 'https://www.zhihu.com/billboard' 129 | } 130 | } 131 | } 132 | function fixQuestionPage () { 133 | const sConfig = window.localStorage 134 | let cssFix = document.createElement('style') 135 | // 吸底的评论栏 136 | cssFix.innerHTML += `.RichContent-actions{bottom:auto !important;}` 137 | // 直接屏蔽顶部问题相关 138 | if (sConfig.showQuestion === 'false') { 139 | cssFix.innerHTML += `.QuestionHeader-footer{display:none !important;}` 140 | cssFix.innerHTML += `.QuestionHeader{display:none !important;}` 141 | cssFix.innerHTML += `.Question-main{margin:0 !important;}` 142 | } 143 | // 问题页面登录弹窗 144 | //cssFix.innerHTML += `.Modal-backdrop{background-color: transparent;}` 145 | //cssFix.innerHTML += `.signFlowModal{display:none !important;}` 146 | cssFix.innerHTML += `.ysn1om,.css-1hwwfws,.css-1ynzxqw{display:none !important;}` 147 | const but = document.getElementsByClassName('Button Modal-closeButton Button--plain')[0] 148 | but.click() 149 | // 顶部关键词 150 | cssFix.innerHTML += `.QuestionHeader-tags{display:none !important;}` 151 | // 问题相关撑满 152 | cssFix.innerHTML += `.QuestionHeader-content{padding-left:0}` 153 | cssFix.innerHTML += `.QuestionHeader-footer{display:none !important;}` 154 | // cssFix.innerHTML += `.QuestionHeader-main {margin:10px;}' 155 | cssFix.innerHTML += `.QuestionHeader{width:694px;margin:0 auto;padding:0;min-width:auto;}` 156 | // 未展开时内容居中 157 | cssFix.innerHTML += `.ListShortcut{margin:0 auto;}` 158 | // 展开时居中 159 | cssFix.innerHTML += `.Question-sideColumn{display:none;}` 160 | cssFix.innerHTML += `.Question-mainColumn{margin:0 auto;}` 161 | // 内容图片/视频最大300px 162 | cssFix.innerHTML += `.origin_image{max-width:300px !important;}` 163 | cssFix.innerHTML += `.RichText-video{max-width:300px !important;}` 164 | // 内容链接去特征 165 | cssFix.innerHTML += 166 | `.LinkCard{margin:auto !important;display:inline !important;}.LinkCard-content{background-color: transparent;}.LinkCard-title{color:#999 !important}` 167 | // 点赞 168 | cssFix.innerHTML += 169 | `.VoteButton{color:#999 !important;background: none; !important}` 170 | // 评论展开宽度 171 | cssFix.innerHTML += `.Modal--fullPage{width:650px}` 172 | // 评论展开关闭按钮复位 173 | cssFix.innerHTML += `.Modal-closeButton{right:0;}` 174 | cssFix.innerHTML += `.Modal-closeIcon{fill:#919191;}` 175 | // 广告商品链接 176 | cssFix.innerHTML += 177 | `.RichText-MCNLinkCardContainer{display:none !important;}` 178 | // 夹缝广告 179 | cssFix.innerHTML += 180 | `.Pc-word{display:none !important;}` 181 | document.getElementsByTagName('head')[0].appendChild(cssFix) 182 | // 右侧问题相关 183 | document.getElementsByClassName('QuestionHeader-side')[1].style.display = 184 | 'none' 185 | document.getElementsByClassName('Question-sideColumn')[0].style.display = 186 | 'none' 187 | // 顶部问题标题 188 | document.getElementsByTagName('header')[0].style.display = 'none' 189 | // 内容撑满 190 | document.getElementsByClassName('Question-main')[0].style.width = 'auto' 191 | document.getElementsByClassName('Question-main')[0].style.padding = '0' 192 | document.getElementsByClassName('Question-mainColumn')[0].style.margin = 193 | '0 auto' 194 | } 195 | function fixSearchPage () { 196 | let cssFix = document.createElement('style') 197 | // header 198 | cssFix.innerHTML += `header{display:none !important;}` 199 | // SearchTabs 200 | cssFix.innerHTML += `.SearchTabs{display:none !important;}` 201 | // SearchSideBar 202 | cssFix.innerHTML += `.SearchSideBar{display:none !important;}` 203 | // CornerButtons 204 | cssFix.innerHTML +=`.CornerButtons{display:none !important;}` 205 | // .SearchMain 206 | cssFix.innerHTML += 207 | `.SearchMain{width:100% !important;margin: 0 !important;}` 208 | // Search-container 209 | cssFix.innerHTML += 210 | `.Search-container{width: auto !important;min-height: auto !important;margin:none !important;}` 211 | cssFix.innerHTML += `.SearchSections{width:auto !important}` 212 | // 点赞 213 | cssFix.innerHTML += 214 | `.VoteButton{color:#999 !important;background: none; !important}` 215 | // 内容图片/视频最大300px 216 | cssFix.innerHTML += `.origin_image{max-width:300px !important;}` 217 | cssFix.innerHTML += `.RichText-video{max-width:300px !important;}` 218 | document.getElementsByTagName('head')[0].appendChild(cssFix) 219 | } 220 | function fixZhuanLan () { 221 | let cssFix = document.createElement('style') 222 | cssFix.innerHTML +=`.Recommendations-Main{display:none !important;}` 223 | document.getElementsByTagName('head')[0].appendChild(cssFix) 224 | } 225 | function fixHomePage () { 226 | let cssFix = document.createElement('style') 227 | cssFix.innerHTML += `.GlobalSideBar{display:none !important;}` 228 | cssFix.innerHTML += `.Topstory-container{width:100% !important;padding:0 !important}` 229 | cssFix.innerHTML += `.Topstory-mainColumn{width:100% !important;}` 230 | document.getElementsByTagName('head')[0].appendChild(cssFix) 231 | } 232 | function hideAuthor () { 233 | const answerList = document.getElementsByClassName('List-item') 234 | for (let index = 0; index < answerList.length; index++) { 235 | const obj = answerList[index] 236 | if(obj.innerHTML.includes('本内容版权为知乎及版权方所有,侵权必究')) 237 | { 238 | obj.style.display = 'none' 239 | } 240 | const key = JSON.parse(obj.getElementsByClassName('ContentItem AnswerItem')[0].getAttribute("data-zop")) 241 | if (key === null) { 242 | return 243 | } 244 | const blackList = window.localStorage.blackList.split(',') 245 | blackList.forEach(name => { 246 | if (key.authorName === name) { 247 | obj.style.display = 'none' 248 | } 249 | }); 250 | } 251 | } 252 | function fixPageWidth(){ 253 | let page = document.querySelector(".Question-mainColumn") 254 | let header = document.querySelector(".QuestionHeader") 255 | let headerCont = document.getElementsByClassName("QuestionHeader-content") 256 | page.style.width = window.localStorage.pageWidth 257 | header.style.width = window.localStorage.pageWidth 258 | headerCont[1].style.width = '100%' 259 | } 260 | })() 261 | --------------------------------------------------------------------------------