/
raw_copy.min.js
1 lines (1 loc) · 1.29 KB
/
raw_copy.min.js
1
!function(){function e(e){function o(o){try{d=!0;for(var r=0;r<e.length;++r){var n=e[r][0],l=e[r][1];if(o.clipboardData)o.clipboardData.setData(n,l);else{if("text/plain"!=n)return void(a=new Error("MIME type "+n+" is not supported on Internet Explorer"));t.clipboardData.setData("Text",l)}}o.preventDefault()}catch(e){a=e}}"string"==typeof e&&(e=[["text/plain",e]]);for(var r={},n=0;n<e.length;++n){if(r[e[n][0]])throw new Error("Data array contains duplicated MIME type");r[e[n][0]]=!0}var a=null,d=!1;document.body.addEventListener("copy",o);var l;try{(l=document.createElement("textarea")).style.border="0",l.style.padding="0",l.style.margin="0",l.style.position="absolute",l.style.left="-9999px";var i=window.pageYOffset||document.documentElement.scrollTop;l.style.top=i+"px",l.setAttribute("readonly",""),l.value="a",document.body.appendChild(l),l.select(),l.setSelectionRange(0,l.value.length);var c;try{c=document.execCommand("copy")}catch(e){throw new Error("An error was thrown by ExecCommand: "+e)}if(a)throw a;if(!c)throw new Error("ExecCommand copy failed");if(!d)throw new Error("This browser does not support the copy clipboard event")}finally{document.body.removeEventListener("copy",o),document.body.removeChild(l)}}var t=this;"undefined"!=typeof module&&module.exports?module.exports=e:t.raw_copy=e}();