1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
|
(function() { 'use strict'; window.addEventListener('load', () => { const stepInterval = 1000; const maxTime = 10 * stepInterval; const startTime = new Date(); const endTime = startTime.getTime() + maxTime; const input = document.createElement('input'); const timer =setInterval(() => { const currentTime = new Date().getTime(); if (currentTime > endTime) return; const category = [...document.querySelectorAll('.opblock-tag')]; if (category.length == 0) { return; }; category.forEach(dom => { dom.addEventListener('click', () => { setTimeout(() => { const sub = dom.nextElementSibling; if (sub.tagName == 'NOSCRIPT') return; const urlDomList = sub.querySelectorAll('.opblock-summary') urlDomList.forEach(urlDom => { const path = urlDom.querySelector('.opblock-summary-path').innerText; const icon = document.createElement('span'); icon.innerText = 'copy' icon.style.padding = '0 4px'; icon.addEventListener('click', (e) => { e.stopPropagation(); document.body.appendChild(input); input.value = path; input.select(); document.execCommand('copy'); document.body.removeChild(input); const tip = document.createElement('div'); tip.innerText = '复制成功'; tip.style.position = 'fixed'; tip.style.top = '20px'; tip.style.right = '20px'; tip.style.padding = '10px 20px'; tip.style.backgroundColor = '#52c41a'; tip.style.color = '#fff'; tip.style.borderRadius = '4px'; document.body.appendChild(tip); setTimeout(() => { document.body.removeChild(tip); }, stepInterval); }); urlDom.appendChild(icon); }) }, 0) }) }) clearInterval(timer); return; }, stepInterval); }) })();
|