// ==UserScript== // @name csdn免登录复制 // @namespace xyz // @version 1.4 // @description csdn免登录复制;csdn免登录复制;在陌生电脑使用,防止隐私泄露;免登录便捷复制,方便工作 // @match *://*.csdn.net/* // @grant none // @icon https://img-home.csdnimg.cn/images/20201124032511.png // ==/UserScript== (function() { 'use strict'; if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', addCustomHtml) } else { addCustomHtml() } function addCustomHtml() { const optBoxes = document.querySelectorAll('div.opt-box'); if (optBoxes.length > 0) { optBoxes.forEach(optBox => { const customHtml = `      
`; optBox.insertAdjacentHTML('afterbegin', customHtml); const button = optBox.querySelector('#custom-button'); if (button) { button.addEventListener('click', function() { alert('按钮被点击了!') }) } }) } else { console.log('未找到class为opt-box的div元素') } } })();