Files
dpl/theme/Fuc/assets/clipboard.mjs
T
hellcat 0501711267 feat(fuc-xb): prepare isolated staging theme and VIP auto upgrades
Port the Fuc 0.12.0 frontend and default-off VIP plugin. Include the previously approved password-reset token revocation. Deploy only to an independent FUC-XB test instance; no production cutover.
2026-11-04 13:44:33 +08:00

10 lines
748 B
JavaScript

export async function copyText(text,{clipboard=globalThis.navigator?.clipboard,document=globalThis.document}={}){
if(clipboard?.writeText){try{await clipboard.writeText(text);return;}catch{}}
// Same fallback used by the original ClipboardJS, including HTTP local previews.
const active=document.activeElement,input=document.createElement('textarea');
input.value=text;input.readOnly=true;input.style.cssText='position:fixed;left:-9999px;top:0';
document.body.append(input);
try{input.focus({preventScroll:true});input.select();input.setSelectionRange(0,input.value.length);if(!document.execCommand?.('copy'))throw Error('复制失败,请选中链接手动复制');}
finally{input.remove();if(active?.isConnected)active.focus();}
}