删除主页和问题页的app按钮,回答页标题栏增加跳转,主要为了适配Via浏览器
// ==UserScript==
// @name 隐藏手机端知乎跳转app按钮
// @namespace none
// @version 1.0.0.6
// @description 删除主页和问题页的app按钮,回答页标题栏增加跳转,主要为了适配Via浏览器
// @author ming
// @match https://www.zhihu.com/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=tampermonkey.net
// @grant none
// ==/UserScript==
(function () {
'use strict';
const removeDiv = () => {
const need_remove = [
'div.OpenInAppButton.is-higher.css-189wwwq',
'css-wfkf2m',
'OpenInAppButton is-higher css-189wwwq',
'css-1gapyfo',
]
for (const name of need_remove) {
const elements = document.getElementsByClassName(name)
if (elements.length > 0) {
elements[0].remove()
}
}
const btn = document.querySelector('button.Button.Button--secondary.Button--grey.css-ebmf5v')
if (btn) { btn.click() }
loaded()
}
//via不会触发load事件
var run_once = false
const loaded = () => {
if (run_once)
return
run_once = true
let quest_link = window.location.href.split("/answer")
if (quest_link.length > 0) {
const questionDiv = document.querySelector('div[data-za-detail-view-element_name="Question"].QuestionHeader-title')
const link = document.createElement('a')
link.href = quest_link[0]
link.textContent = `${questionDiv.textContent} (超链接)`
questionDiv.textContent = ''
questionDiv.appendChild(link)
}
}
window.addEventListener('load', loaded)
const observer = new MutationObserver(removeDiv)
observer.observe(document.body, { childList: true, subtree: true })
})()
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址