// ==UserScript==
// @name 知乎Plus
// @namespace zhihu_plus
// @version 0.3
// @description 知乎Plus: 1. 暗色极简阅读模式;2. 去除官方或用户插入的广告
// @author Gaofang Huang
// @match https://*.zhihu.com/*
// @match https://v.vzuu.com/video/*
// @match https://video.zhihu.com/video/*
// @connect zhihu.com
// @connect vzuu.com
// @require https://cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.min.js
// @require https://cdn.bootcdn.net/ajax/libs/jquery-cookie/1.4.1/jquery.cookie.min.js
// @grant none
// @downloadURL https://update.greasyfork.icu/scripts/411416/%E7%9F%A5%E4%B9%8EPlus.user.js
// @updateURL https://update.greasyfork.icu/scripts/411416/%E7%9F%A5%E4%B9%8EPlus.meta.js
// ==/UserScript==
// 图标-眼睛关
const iconEyeClose = ``
// 图标-眼睛开
const iconEyeOpen = ``
;(function () {
'use strict'
// 添加自定义样式
const userStyle = document.createElement('style')
userStyle.innerHTML = createUserStyle()
$('head').append(userStyle)
$('html').attr('data-plus', 'true')
// 添加插件按钮
const $plusButton = $(
`
`
)
$plusButton.click(() => {
if ($('html').attr('data-plus') == 'true') {
$('html').attr('data-plus', 'false')
$('.switch-plus-icon').html(iconEyeClose)
$.cookie('plusMode', 0, { expires: 365, path: '/', domain: 'zhihu.com' })
} else {
$('html').attr('data-plus', 'true')
$('.switch-plus-icon').html(iconEyeOpen)
$.cookie('plusMode', 1, { expires: 365, path: '/', domain: 'zhihu.com' })
}
})
if ($('.switch-plus-btn').length === 0) {
$('body').append($plusButton)
}
if (Number($.cookie('plusMode')) === 1) {
$('html').attr('data-plus', 'true')
$('.switch-plus-icon').html(iconEyeOpen)
} else {
$('html').attr('data-plus', 'false')
$('.switch-plus-icon').html(iconEyeClose)
}
// 外站地址直接跳转
const webHost = window.location.host
if (webHost === 'link.zhihu.com') {
const rule = /target=(.+?)(&|$)/
const regRet = location.search.match(rule)
if (regRet && regRet.length === 3) {
location.href = decodeURIComponent(regRet[1])
}
}
})()
function createUserStyle() {
return `
.switch-plus-btn {
position: fixed;
right: 40px;
top: 15px;
cursor: pointer;
font-size: 12px;
z-index: 999;
}
.switch-plus-icon svg {
width: 24px;
height: 24px;
}
/* 滚动条优化 */
html[data-plus=true] .Favlists-items::-webkit-scrollbar,
html[data-plus=true] .highlight pre::-webkit-scrollbar,
html[data-plus=true] body::-webkit-scrollbar,
html[data-plus=true] .CommentListV2::-webkit-scrollbar {
width: 4px;
height: 4px;
}
html[data-plus=true] .Favlists-items::-webkit-scrollbar-thumb,
html[data-plus=true] .highlight pre::-webkit-scrollbar-thumb,
html[data-plus=true] body::-webkit-scrollbar-thumb,
html[data-plus=true] .CommentListV2::-webkit-scrollbar-thumb {
background-color: rgb(133 144 166 / 0.2);
transition: 0.2s;
border-radius: 2px;
}
html[data-plus=true] .Favlists-items::-webkit-scrollbar-track,
html[data-plus=true] .highlight pre::-webkit-scrollbar-track,
html[data-plus=true] body::-webkit-scrollbar-track,
html[data-plus=true] .CommentListV2::-webkit-scrollbar-track {
background-color: rgba(0,0,0,0);
}
html[data-plus=true] .Favlists-items::-webkit-scrollbar-thumb,
html[data-plus=true] .highlight pre::-webkit-scrollbar-thumb,
html[data-plus=true] body::-webkit-scrollbar-thumb,
html[data-plus=true] .CommentListV2:hover::-webkit-scrollbar-thumb {
background-color: rgb(133 144 166 / 0.6);
}
/* 隐藏界面 */
html[data-plus=true] .SearchSideBar,
html[data-plus=true] .SearchTabs,
html[data-plus=true] .PostIndex-Contributions,
html[data-plus=true] .Recommendations-Main,
html[data-plus=true] .ColumnPageHeader,
html[data-plus=true] .Topstory-mainColumn .TopstoryItem--advertCard,
html[data-plus=true] .TopstoryMain .TopstoryItem--advertCard,
html[data-plus=true] .RichText-MCNLinkCardContainer,
html[data-plus=true] .Reward,
html[data-plus=true] .ContentItem-meta .AuthorInfo + .Labels,
html[data-plus=true] .QuestionHeader,
html[data-plus=true] .Question-sideColumn,
html[data-plus=true] .GlobalSideBar,
html[data-plus=true] .AppHeader {
display: none !important;
}
/* 布局调整 */
html[data-plus=true] .SearchMain,
html[data-plus=true] .Question-mainColumn,
html[data-plus=true] .Topstory-mainColumn {
margin-left: auto;
margin-right: auto;
}
/* 全局背景色 */
html[data-plus=true] body {
background: #333333;
}
/* 卡片背景色 & 内容工具栏 */
html[data-plus=true] .Post-content {
background: transparent;
}
html[data-plus=true] .HotListNavEditPad {
background: #c9cdd8;
border-color: #b6b8c3;
}
html[data-plus=true] .HotListNav-item--deleteButton {
background: #a4adb3;
}
html[data-plus=true] .RichContent-actions.is-fixed,
html[data-plus=true] .Post-RichTextContainer,
html[data-plus=true] .ProfileHeader-wrapper,
html[data-plus=true] .CommentsV2-withPagination,
html[data-plus=true] .CommentEditorV2-inputWrap--active,
html[data-plus=true] .CommentsV2-footer,
html[data-plus=true] .CommentListV2-header-divider,
html[data-plus=true] .Topbar,
html[data-plus=true] .Modal-inner,
html[data-plus=true] .InputLike,
html[data-plus=true] .HotItem,
html[data-plus=true] .HotListNav-wrapper,
html[data-plus=true] .ContentItem-actions,
html[data-plus=true] .Card {
background: #bfc2ca;
}
html[data-plus=true] .Post-Main .Post-Title {
color: #bfc2ca;
}
html[data-plus=true] .Post-Header {
margin-bottom: 20px;
}
html[data-plus=true] .Post-RichTextContainer {
box-sizing: border-box;
padding: 20px;
border-radius: 8px;
}
html[data-plus=true] .RichContent-actions {
padding-left: 10px;
}
html[data-plus=true] .Highlight em {
color: #5f649c;
}
/* 点赞按钮 */
html[data-plus=true] .Post-SideActions button.like .Post-SideActions-icon,
html[data-plus=true] .Tag,
html[data-plus=true] .HotListNav-item,
html[data-plus=true] .VoteButton {
background: rgb(138 138 138 / 10%);
color: #8590a6;
}
html[data-plus=true] .HotListNav-item.is-active {
background: rgb(32 43 74 / 10%);
color: #8590a6;
}
html[data-plus=true] .Button--blue {
color: #7d94a9;
border-color: #8fa5b9;
}
html[data-plus=true] .VoteButton.is-active {
background: rgb(51 57 125 / 10%);
color: #8590a6;
}
html[data-plus=true] .Button--primary.Button--blue {
background: rgb(191 194 202);
color: #50638a;
}
html[data-plus=true] .Modal-closeIcon {
fill: #8590a6;
}
html[data-plus=true] .Post-SideActions button.like {
color: #8590a6;
}
/* tab栏 & 卡片 */
html[data-plus=true] .Favlists-item,
html[data-plus=true] .CommentsV2-pagination,
html[data-plus=true] .CommentsV2-withPagination,
html[data-plus=true] .CommentEditorV2-inputWrap--active,
html[data-plus=true] .NestComment .NestComment--child:after,
html[data-plus=true] .NestComment--rootComment:after,
html[data-plus=true] .NestComment:not(:last-child):after,
html[data-plus=true] .Topbar,
html[data-plus=true] .List-item+.List-item:after,
html[data-plus=true] .List-header,
html[data-plus=true] .Topstory--old .HotItem:not(:first-child),
html[data-plus=true] .Topstory--old .HotListNav,
html[data-plus=true] .Topstory-mainColumnCard .Card:not(.Topstory-tabCard),
html[data-plus=true] .Topstory-tabs {
border-color: rgb(181 185 197);
}
html[data-plus=true] .TopstoryTabs-link {
color: #8590a6;
}
html[data-plus=true] .TopstoryTabs-link.is-active {
color: #333333;
font-weight: 600;
}
/* 查看更多 */
html[data-plus=true] .ContentItem-more {
color: rgb(106 114 119);
}
/* 卡片封面 & 标识 */
html[data-plus=true] .css-18biwo,
html[data-plus=true] .Avatar,
html[data-plus=true] .HotItem-img,
html[data-plus=true] .RichContent-cover {
opacity: 0.45;
}
/* 返回顶部按钮 */
html[data-plus=true] .CornerButton {
background: #484b54;
}
/* 热度序号 */
html[data-plus=true] .HotItem-hot {
color: #4d72ab;
}
html[data-plus=true] .HotItem-label {
background-color: #4d72ab !important;
}
/* 没有更多 */
html[data-plus=true] .HotList-end {
color: #47494c;
}
html[data-plus=true] .HotList-end:after, .HotList-end:before {
background-color: #47494c;
}
/* 评论输入框 */
html[data-plus=true] .ZVideoLinkCard-info,
html[data-plus=true] .CommentsV2-footer {
background-color: #b9beca;
}
html[data-plus=true] .CommentsV2-footer {
border-color: #b6b9c1;
}
html[data-plus=true] .CommentEditorV2-inputWrap {
border-color: #b6b9c1;
background-color: #b9beca;
}
`
}