用户:RedDragon/common.js:修订间差异
来自Rizline中文维基
更多操作
RedDragon(留言 | 贡献) (创建页面,内容为“$(function() { var shortlink = document.querySelector('.title-shortlink'); if (shortlink) { shortlink.removeAttribute('href'); shortlink.addEventListener('click', function(e) { e.preventDefault(); navigator.clipboard.writeText(this.textContent).then(function() { var originalText = shortlink.textContent; shortlink.textContent = '已复制!';…”) |
小 |
||
| 第1行: | 第1行: | ||
$(function() { | $(function() { | ||
var shortlink = document.querySelector('.title-shortlink') | var shortlink = document.querySelector('.title-shortlink') | ||
if (shortlink) { | if (shortlink) { | ||
shortlink.removeAttribute('href') | shortlink.removeAttribute('href') | ||
shortlink.addEventListener('click', function(e) { | shortlink.addEventListener('click', function(e) { | ||
e.preventDefault() | e.preventDefault() | ||
navigator.clipboard.writeText(this.textContent).then(function() { | navigator.clipboard.writeText(this.textContent).then(function() { | ||
var originalText = shortlink.textContent | var originalText = shortlink.textContent | ||
shortlink. | shortlink.title = '已复制!' | ||
setTimeout(function() { | setTimeout(function() { | ||
shortlink. | shortlink.title = '点击复制链接' | ||
}, 2000) | }, 2000) | ||
}).catch(function(err) { | }).catch(function(err) { | ||
console.error('失败: ', err) | console.error('失败: ', err) | ||
}) | }) | ||
}) | }) | ||
shortlink.style.cursor = 'pointer' | shortlink.style.cursor = 'pointer' | ||
shortlink.title = '点击复制链接' | shortlink.title = '点击复制链接' | ||
} | } | ||
}) | }) | ||
2025年8月16日 (六) 20:42的版本
$(function() {
var shortlink = document.querySelector('.title-shortlink')
if (shortlink) {
shortlink.removeAttribute('href')
shortlink.addEventListener('click', function(e) {
e.preventDefault()
navigator.clipboard.writeText(this.textContent).then(function() {
var originalText = shortlink.textContent
shortlink.title = '已复制!'
setTimeout(function() {
shortlink.title = '点击复制链接'
}, 2000)
}).catch(function(err) {
console.error('失败: ', err)
})
})
shortlink.style.cursor = 'pointer'
shortlink.title = '点击复制链接'
}
})