\d+) 个。/
)
if (data) {
const { total, accepted } = data.groups
el.textContent += ` (${accepted} / ${total})`
if (accepted == total) {
el.textContent += ' Accepted!'
el.style.color = '#fff'
el.style.backgroundColor = '#42ab0e'
} else {
el.textContent += ' Wrong Answer.'
el.style.backgroundColor = '#ffe4e4'
el.style.color = '#ff0424'
}
}
document.querySelectorAll('#test-result-detail > p').forEach(e => e.remove())
})()
;(() => {
if (!location.href.includes('history.php')) return
// history.php 显示优化
const update = () => {
const parser = new DOMParser()
const el = document.querySelector('.dp-highlighter')
const code = parser.parseFromString(
`${el.highlighter.originalCode}
`,
'text/html'
).body.textContent
const copy_button = document.createElement('button')
copy_button.textContent = '复制'
copy_button.classList.add('copy-button')
document.querySelector('.dp-highlighter .tools').replaceWith(copy_button)
copy_button.addEventListener('click', () =>
navigator.clipboard.writeText(code).then(
() => {
if (copy_button.textContent == '复制')
setTimeout(() => (copy_button.textContent = '复制'), 1000)
copy_button.textContent = '复制成功'
},
err => {
if (copy_button.textContent == '复制')
setTimeout(() => (copy_button.textContent = '复制'), 2000)
copy_button.textContent = '复制失败'
}
)
)
}
document
.querySelectorAll('#submitlist')
.forEach(el => el.addEventListener('click', () => setTimeout(update, 100)))
addEventListener('load', update)
})()