打开/关闭菜单
打开/关闭外观设置菜单
打开/关闭个人菜单
未登录
未登录用户的IP地址会在进行任意编辑后公开展示。

用户:RedDragon/common.js:修订间差异

来自Rizline中文维基
RedDragon
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.textContent = '已复制!';
                 shortlink.title = '已复制!'
                  
                  
                 setTimeout(function() {
                 setTimeout(function() {
                     shortlink.textContent = originalText;
                     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 = '点击复制链接'
    }
})