写了个 V2EX 的优化回复显示的脚本,只适配了单页的情况:
// match regex:
//
https://www.v2ex.com/t/732305*```javascript
function $(element, selector) {
return [...element.querySelectorAll(selector)]
}
if (window ==
window.top) {
let boxs = document.querySelectorAll('#Main > .box')
let mainBox = boxs[1]
let cells = [...mainBox.getElementsByClassName('cell')]
cells.shift()
let dict = {}
for (let cell of cells) {
let name = $(cell, 'strong > a')[0]?.innerHTML ?? ''
dict[name] = cell
}
for (let cell of cells) {
let replyContent = $(cell, '.reply_content > a')[0]
if (replyContent) {
let replyToName = replyContent.innerHTML
// console.log(replyToName)
dict[replyToName]?.appendChild(cell)
cell.style.marginLeft = '2em'
}
}
}
```