Last active
November 8, 2021 23:21
-
-
Save AllanChain/c3c7adc4fd20b05f61b09d28ce03f2a2 to your computer and use it in GitHub Desktop.
知乎移动端修复
This file contains hidden or 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 Mobile | |
// @version 1.0.2 | |
// @description 知乎移动端修复 | |
// @include https://www.zhihu.com/* | |
// @include https://zhuanlan.zhihu.com/* | |
// @grant GM_addStyle | |
// @run-at document-start | |
// ==/UserScript== | |
function expandRichContent (node) { | |
console.log(node) | |
node.classList.remove('is-collapsed') | |
} | |
function expandRichContentRecursive (node) { | |
node | |
.querySelectorAll('.RichContent.is-collapsed') | |
.forEach(expandRichContent) | |
} | |
console.log('知乎移动端修复正在运行') | |
GM_addStyle(` | |
.DownloadGuide { | |
display: none; | |
} | |
.OpenInAppButton { | |
display: none; | |
} | |
.MobileAppHeader-downloadLink { | |
display: none; | |
} | |
.ModalWrap { | |
display: none; | |
} | |
body.ModalWrap-body { | |
overflow: auto !important; | |
} | |
.ContentItem-expandButton { | |
display: none; | |
} | |
.RichContent-inner { | |
max-height: unset !important; | |
} | |
`) | |
const observer = new MutationObserver((mutations) => { | |
for (const m of mutations) { | |
if ( | |
m.target.classList.contains('RichContent') && | |
m.target.classList.contains('is-collapsed') | |
) { | |
console.log('1', m.target) | |
expandRichContent(m.target) | |
} else { | |
for (const node in m.addedNodes) { | |
if ( | |
node.nodeType === Node.ELEMENT_NODE && | |
node.classList.contains('RichContent') | |
) { | |
console.log('2', node) | |
expandRichContent(node) | |
} | |
} | |
} | |
} | |
}) | |
window.addEventListener('load', function (event) { | |
event.stopImmediatePropagation() | |
expandRichContentRecursive(document) | |
observer.observe(document.documentElement, { | |
childList: true, | |
subtree: true | |
}) | |
}) | |
请问如何注入iOS 15 Safari?目前似乎没有第三方扩展支持 JS 注入
不好意思我不用苹果系的产品所以我不晓得,估计得用其他浏览器。
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
请问如何注入iOS 15 Safari?目前似乎没有第三方扩展支持 JS 注入