blog/js/script.min.510c781c39dbb21b4c76d85c82e2bdf4689220adbb7cd61e49e9d293e442fb42.js
2022-02-22 07:17:00 +00:00

1 line
No EOL
1.3 KiB
JavaScript

document.addEventListener("DOMContentLoaded",function(h){'use strict';if(!document.queryCommandSupported('copy'))return;let a='<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>',d='<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>',e='<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 b(b,c){b.innerHTML=c,setTimeout(()=>{b.innerHTML=a},1e3)}function f(a){let b=window.getSelection(),c=document.createRange();return a.childElementCount===2?c.selectNodeContents(a.children[1]):c.selectNodeContents(a),b.removeAllRanges(),b.addRange(c),b}function c(g){let c=document.createElement("button");c.className="highlight-copy-btn",c.innerHTML=a;let h=g.firstElementChild;c.addEventListener('click',()=>{try{let a=f(h);document.execCommand('copy'),a.removeAllRanges(),b(c,d)}catch(a){console&&console.log(a),b(c,e)}}),g.appendChild(c)}let g=document.getElementsByClassName('highlight');Array.prototype.forEach.call(g,c)},!1)