Last active
December 3, 2020 06:30
-
-
Save walt-w/dbd328699cabef31a2581dcd8f74c474 to your computer and use it in GitHub Desktop.
Clean up Zhihu question page in GreaseMonkey
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Zhihu Cleaner | |
// @namespace http://tampermonkey.net/ | |
// @version 0.2 | |
// @description Cleanup Zhihu CSS | |
// @author W | |
// @match https://www.zhihu.com/question/* | |
// @grant GM_addStyle | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
var style = ` | |
html { | |
margin-bottom: 0px; | |
margin-right: 0px; | |
} | |
.QuestionHeaderTopicMeta.Card { | |
display: none; | |
} | |
.Modal-wrapper { | |
display: none; | |
} | |
.AppHeader { | |
display:none; | |
} | |
.Question-sideColumn { | |
display:none; | |
} | |
.QuestionHeader-side { | |
display:none; | |
} | |
.QuestionHeader-topics { | |
display:none; | |
} | |
.QuestionHeader-footer-main { | |
display:none; | |
} | |
.QuestionHeader-title .Button { | |
display:none; | |
} | |
.Avatar{ | |
display: none; | |
} | |
.QuestionHeader-title { | |
font-weight: normal | |
} | |
.AuthorInfo-name { | |
font-weight: normal | |
} | |
.QuestionHeader { | |
padding: 0px; | |
} | |
.Sticky--holder { | |
display: none !important; | |
} | |
.VoteButton { | |
color: #8590a6; | |
} | |
div.ContentItem-actions > span { | |
display: none; | |
} | |
div.Popover.ShareMenu.ContentItem-action { | |
display: none; | |
} | |
div.ContentItem-actions > button:nth-child(5) { | |
display: none; | |
} | |
.Question-mainColumn { | |
width: 60%; | |
} | |
.QuestionHeader-content { | |
width: 60%; | |
padding: inherit; | |
margin: inherit; | |
} | |
.CornerButton { | |
display: none; | |
} | |
.Pc-word { | |
display: none; | |
} | |
.Question-mainColumnLogin { | |
display: none; | |
} | |
` | |
function change_favicon(img) { | |
var favicon = document.querySelector('link[rel="shortcut icon"]'); | |
if (!favicon) { | |
favicon = document.createElement('link'); | |
favicon.setAttribute('rel', 'shortcut icon'); | |
var head = document.querySelector('head'); | |
head.appendChild(favicon); | |
} | |
favicon.setAttribute('type', 'image/png'); | |
favicon.setAttribute('href', img); | |
} | |
function update_title(text) { | |
setInterval(()=>{ | |
var title = document.querySelector("head > title") | |
title.innerHTML = text | |
}, 5000) | |
} | |
function update_html() { | |
var timer = setInterval(()=>{ | |
clearInterval(timer) | |
var html = document.querySelector("html") | |
html.style.overflow = "auto" | |
}, 1000) | |
} | |
GM_addStyle(style) | |
change_favicon('https://www.baidu.com/favicon.ico'); | |
update_title('https://www.baidu.com/'); | |
update_html(); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment