您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Sticks the first line of all comments in the visible comment tree to the top of the screen so you always know where exactly you are. See the screenshots for a better understanding.
当前为
// ==UserScript== // @name Hacker News Contextual Comments (sticky tree) // @version 0.1 // @description Sticks the first line of all comments in the visible comment tree to the top of the screen so you always know where exactly you are. See the screenshots for a better understanding. // @author phil294 // @match https://news.ycombinator.com/item?id=* // @icon https://www.google.com/s2/favicons?domain=ycombinator.com // @grant GM_addStyle // @namespace https://gf.zukizuki.org/users/779094 // ==/UserScript== GM_addStyle(` tr.comtr { position: sticky; display: block; background: #f6f6ef; min-height: 40px; cursor: pointer; } tr.comtr.noshow { display: none; }`) const sticky_row_height = 40 let i_zindex = 0 for(const com of document.querySelectorAll('tr.comtr')) { const nesting_level = com.querySelector('.ind > img').width / 40 com.style.top = nesting_level * sticky_row_height com.style.zindex = ++i_zindex com.onclick = async () => { com.querySelector('a.togg').click() com.style.position = 'static' com.scrollIntoView({block: "start", inline: "nearest", behavior: "smooth"}) com.style.position = 'sticky' } }