mg696 commited on
Commit
088ddef
·
verified ·
1 Parent(s): 5c50643

v115: add isolated debug copy fix script

Browse files
Files changed (1) hide show
  1. copy-fix-v115.js +47 -0
copy-fix-v115.js ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // copy-fix-v115.js
2
+ (function(){
3
+ function install(){
4
+ const btn=document.getElementById('debug-copy-btn');
5
+ const logEl=document.getElementById('debug-log');
6
+ if(!btn||!logEl||btn.__copyFixV115)return;
7
+ btn.__copyFixV115=true;
8
+ function setStatus(ok){
9
+ btn.textContent=ok?'✅コピー完了':'⚠コピー失敗';
10
+ btn.style.background=ok?'#064':'#700';
11
+ btn.style.color='#fff';
12
+ setTimeout(()=>{btn.textContent='📋 Copy All';btn.style.background='';btn.style.color='';},1800);
13
+ }
14
+ async function doCopy(e){
15
+ if(e){e.preventDefault();e.stopPropagation();e.stopImmediatePropagation&&e.stopImmediatePropagation();}
16
+ const text=logEl.innerText||'';
17
+ try{
18
+ if(navigator.clipboard&&navigator.clipboard.writeText){
19
+ await navigator.clipboard.writeText(text);
20
+ setStatus(true);
21
+ return;
22
+ }
23
+ }catch(err){}
24
+ try{
25
+ const ta=document.createElement('textarea');
26
+ ta.value=text;
27
+ ta.setAttribute('readonly','');
28
+ ta.style.position='fixed';
29
+ ta.style.left='0';
30
+ ta.style.top='0';
31
+ ta.style.width='2px';
32
+ ta.style.height='2px';
33
+ ta.style.opacity='0.01';
34
+ document.body.appendChild(ta);
35
+ ta.focus();
36
+ ta.select();
37
+ ta.setSelectionRange(0,ta.value.length);
38
+ const ok=document.execCommand('copy');
39
+ document.body.removeChild(ta);
40
+ setStatus(!!ok);
41
+ }catch(err){setStatus(false)}
42
+ }
43
+ ['click','touchend','pointerup'].forEach(ev=>btn.addEventListener(ev,doCopy,true));
44
+ }
45
+ if(document.readyState==='loading')document.addEventListener('DOMContentLoaded',install);else install();
46
+ setInterval(install,1000);
47
+ })();