blog/js/script.min.a65afe903825231554d9b55b073eb144da4ccf2d2823b216dcbc6cc656c9de76.js

1 line
1.3 KiB
JavaScript
Raw Normal View History

document.addEventListener("DOMContentLoaded",function(){'use strict';if(!document.queryCommandSupported("copy"))return;let e='<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 25 25"><path d="M18 6v-6h-18v18h6v6h18v-18h-6zm-12 10h-4v-14h14v4h-10v10zm16 6h-14v-14h14v14z"/></svg>',s='<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 25 25"><path d="M20.285 2l-11.285 11.567-5.286-5.011-3.714 3.716 9 8.728 15-15.285z"/></svg>',o='<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 25 25"><path d="M23.954 21.03l-9.184-9.095 9.092-9.174-2.832-2.807-9.09 9.179-9.176-9.088-2.81 2.81 9.186 9.105-9.095 9.184 2.81 2.81 9.112-9.192 9.18 9.1z"/></svg>';function t(t,n){t.innerHTML=n,setTimeout(()=>{t.innerHTML=e},1e3)}function i(e){let t=window.getSelection(),n=document.createRange();return e.childElementCount===2?n.selectNodeContents(e.children[1]):n.selectNodeContents(e),t.removeAllRanges(),t.addRange(n),t}function n(a){let n=document.createElement("button");n.className="highlight-copy-btn",n.innerHTML=e;let r=a.firstElementChild;n.addEventListener("click",()=>{try{let e=i(r);document.execCommand("copy"),e.removeAllRanges(),t(n,s)}catch(e){console&&console.log(e),t(n,o)}}),a.appendChild(n)}let a=document.getElementsByClassName("highlight");Array.prototype.forEach.call(a,n)},!1)