Reputation: 2845
hi all i am using the following code on address bar and works properly by outputting data.
javascript: alert(document.getElementsByTagName("html")[0].innerHTML );
How i can change the code so it copies the output data to clipboard so i can paste it somewhere later ? I tried following but did not work! Thanks in advance.
did not copy the data to clipboard:
javascript: alert(document.getElementsByTagName("html")[0].innerHTML ,document.execCommand("copy"));
Upvotes: 2
Views: 2036
Reputation: 1
<a href="javascript:(function()%7Bvar%20clipboard%3D%7B%7D%3Bclipboard.copy%3Dfunction()%7Bfunction%20t()%7Bn%3D!1%2Co%3Dnull%2Cr%26%26window.getSelection().removeAllRanges()%2Cr%3D!1%7Dfunction%20e()%7Bvar%20t%3Ddocument.getSelection()%3Bif(!document.queryCommandEnabled(%22copy%22)%26%26t.isCollapsed)%7Bvar%20e%3Ddocument.createRange()%3Be.selectNodeContents(document.body)%2Ct.removeAllRanges()%2Ct.addRange(e)%2Cr%3D!0%7D%7Dvar%20n%3D!1%2Co%3Dnull%2Cr%3D!1%3Breturn%20document.addEventListener(%22copy%22%2Cfunction(t)%7Bif(n)%7Bfor(var%20e%20in%20o)t.clipboardData.setData(e%2Co%5Be%5D)%3Bt.preventDefault()%7D%7D)%2Cfunction(r)%7Breturn%20new%20Promise(function(i%2Ca)%7Bfunction%20c(n)%7Btry%7Bif(document.execCommand(%22copy%22))t()%2Ci()%3Belse%7Bif(n)throw%20t()%2Cnew%20Error(%22Unable%20to%20copy.%20Perhaps%20it's%20not%20available%20in%20your%20browser%3F%22)%3Be()%2Cc(!0)%7D%7Dcatch(o)%7Bt()%2Ca(o)%7D%7Dn%3D!0%2C%22string%22%3D%3Dtypeof%20r%3Fo%3D%7B%22text%2Fplain%22%3Ar%7D%3Ar%20instanceof%20Node%3Fo%3D%7B%22text%2Fhtml%22%3A(new%20XMLSerializer).serializeToString(r)%7D%3Ar%20instanceof%20Object%3Fo%3Dr%3Aa(%22Invalid%20data%20type.%20Must%20be%20string%2C%20DOM%20node%2C%20or%20an%20object%20mapping%20MIME%20types%20to%20strings.%22)%2Cc(!1)%7D)%7D%7D()%2Cclipboard.paste%3Dfunction()%7Bvar%20t%2Ce%2Cn%3D!1%3Breturn%20document.addEventListener(%22paste%22%2Cfunction(o)%7Bif(n)%7Bn%3D!1%2Co.preventDefault()%3Bvar%20r%3Dt%3Bt%3Dnull%2Cr(o.clipboardData.getData(e))%7D%7D)%2Cfunction(o)%7Breturn%20new%20Promise(function(r%2Ci)%7Bn%3D!0%2Ct%3Dr%2Ce%3Do%7C%7C%22text%2Fplain%22%3Btry%7Bdocument.execCommand(%22paste%22)%7C%7C(n%3D!1%2Ci(new%20Error(%22Unable%20to%20paste.%20Pasting%20only%20works%20in%20Internet%20Explorer%20at%20the%20moment.%22)))%7Dcatch(a)%7Bn%3D!1%2Ci(new%20Error(a))%7D%7D)%7D%7D()%2C%22undefined%22%3D%3Dtypeof%20ClipboardEvent%26%26%22undefined%22!%3Dtypeof%20window.clipboardData%26%26%22undefined%22!%3Dtypeof%20window.clipboardData.setData%26%26(!function(t)%7Bfunction%20e(t%2Ce)%7Breturn%20function()%7Bt.apply(e%2Carguments)%7D%7Dfunction%20n(t)%7Bif(%22object%22!%3Dtypeof%20this)throw%20new%20TypeError(%22Promises%20must%20be%20constructed%20via%20new%22)%3Bif(%22function%22!%3Dtypeof%20t)throw%20new%20TypeError(%22not%20a%20function%22)%3Bthis._state%3Dnull%2Cthis._value%3Dnull%2Cthis._deferreds%3D%5B%5D%2Cu(t%2Ce(r%2Cthis)%2Ce(i%2Cthis))%7Dfunction%20o(t)%7Bvar%20e%3Dthis%3Breturn%20null%3D%3D%3Dthis._state%3Fvoid%20this._deferreds.push(t)%3Avoid%20s(function()%7Bvar%20n%3De._state%3Ft.onFulfilled%3At.onRejected%3Bif(null%3D%3D%3Dn)return%20void(e._state%3Ft.resolve%3At.reject)(e._value)%3Bvar%20o%3Btry%7Bo%3Dn(e._value)%7Dcatch(r)%7Breturn%20void%20t.reject(r)%7Dt.resolve(o)%7D)%7Dfunction%20r(t)%7Btry%7Bif(t%3D%3D%3Dthis)throw%20new%20TypeError(%22A%20promise%20cannot%20be%20resolved%20with%20itself.%22)%3Bif(t%26%26(%22object%22%3D%3Dtypeof%20t%7C%7C%22function%22%3D%3Dtypeof%20t))%7Bvar%20n%3Dt.then%3Bif(%22function%22%3D%3Dtypeof%20n)return%20void%20u(e(n%2Ct)%2Ce(r%2Cthis)%2Ce(i%2Cthis))%7Dthis._state%3D!0%2Cthis._value%3Dt%2Ca.call(this)%7Dcatch(o)%7Bi.call(this%2Co)%7D%7Dfunction%20i(t)%7Bthis._state%3D!1%2Cthis._value%3Dt%2Ca.call(this)%7Dfunction%20a()%7Bfor(var%20t%3D0%2Ce%3Dthis._deferreds.length%3Be%3Et%3Bt%2B%2B)o.call(this%2Cthis._deferreds%5Bt%5D)%3Bthis._deferreds%3Dnull%7Dfunction%20c(t%2Ce%2Cn%2Co)%7Bthis.onFulfilled%3D%22function%22%3D%3Dtypeof%20t%3Ft%3Anull%2Cthis.onRejected%3D%22function%22%3D%3Dtypeof%20e%3Fe%3Anull%2Cthis.resolve%3Dn%2Cthis.reject%3Do%7Dfunction%20u(t%2Ce%2Cn)%7Bvar%20o%3D!1%3Btry%7Bt(function(t)%7Bo%7C%7C(o%3D!0%2Ce(t))%7D%2Cfunction(t)%7Bo%7C%7C(o%3D!0%2Cn(t))%7D)%7Dcatch(r)%7Bif(o)return%3Bo%3D!0%2Cn(r)%7D%7Dvar%20s%3Dn.immediateFn%7C%7C%22function%22%3D%3Dtypeof%20setImmediate%26%26setImmediate%7C%7Cfunction(t)%7BsetTimeout(t%2C1)%7D%2Cl%3DArray.isArray%7C%7Cfunction(t)%7Breturn%22%5Bobject%20Array%5D%22%3D%3D%3DObject.prototype.toString.call(t)%7D%3Bn.prototype%5B%22catch%22%5D%3Dfunction(t)%7Breturn%20this.then(null%2Ct)%7D%2Cn.prototype.then%3Dfunction(t%2Ce)%7Bvar%20r%3Dthis%3Breturn%20new%20n(function(n%2Ci)%7Bo.call(r%2Cnew%20c(t%2Ce%2Cn%2Ci))%7D)%7D%2Cn.all%3Dfunction()%7Bvar%20t%3DArray.prototype.slice.call(1%3D%3D%3Darguments.length%26%26l(arguments%5B0%5D)%3Farguments%5B0%5D%3Aarguments)%3Breturn%20new%20n(function(e%2Cn)%7Bfunction%20o(i%2Ca)%7Btry%7Bif(a%26%26(%22object%22%3D%3Dtypeof%20a%7C%7C%22function%22%3D%3Dtypeof%20a))%7Bvar%20c%3Da.then%3Bif(%22function%22%3D%3Dtypeof%20c)return%20void%20c.call(a%2Cfunction(t)%7Bo(i%2Ct)%7D%2Cn)%7Dt%5Bi%5D%3Da%2C0%3D%3D%3D--r%26%26e(t)%7Dcatch(u)%7Bn(u)%7D%7Dif(0%3D%3D%3Dt.length)return%20e(%5B%5D)%3Bfor(var%20r%3Dt.length%2Ci%3D0%3Bi%3Ct.length%3Bi%2B%2B)o(i%2Ct%5Bi%5D)%7D)%7D%2Cn.resolve%3Dfunction(t)%7Breturn%20t%26%26%22object%22%3D%3Dtypeof%20t%26%26t.constructor%3D%3D%3Dn%3Ft%3Anew%20n(function(e)%7Be(t)%7D)%7D%2Cn.reject%3Dfunction(t)%7Breturn%20new%20n(function(e%2Cn)%7Bn(t)%7D)%7D%2Cn.race%3Dfunction(t)%7Breturn%20new%20n(function(e%2Cn)%7Bfor(var%20o%3D0%2Cr%3Dt.length%3Br%3Eo%3Bo%2B%2B)t%5Bo%5D.then(e%2Cn)%7D)%7D%2C%22undefined%22!%3Dtypeof%20module%26%26module.exports%3Fmodule.exports%3Dn%3At.Promise%7C%7C(t.Promise%3Dn)%7D(this)%2Cclipboard.copy%3Dfunction(t)%7Breturn%20new%20Promise(function(e%2Cn)%7Bif(%22string%22!%3Dtypeof%20t%26%26!(%22text%2Fplain%22in%20t))throw%20new%20Error(%22You%20must%20provide%20a%20text%2Fplain%20type.%22)%3Bvar%20o%3D%22string%22%3D%3Dtypeof%20t%3Ft%3At%5B%22text%2Fplain%22%5D%2Cr%3Dwindow.clipboardData.setData(%22Text%22%2Co)**strong text**%3Br%3Fe()%3An(new%20Error(%22Copying%20was%20rejected.%22))%7D)%7D%2Cclipboard.paste%3Dfunction()%7Breturn%20new%20Promise(function(t%2Ce)%7Bvar%20n%3Dwindow.clipboardData.getData(%22Text%22)%3Bn%3Ft(n)%3Ae(new%20Error(%22Pasting%20was%20rejected.%22))%7D)%7D)%3Bclipboard.copy(document.getElementsByTagName(%22html%22)%5B0%5D.innerHTML)%3Balert(document.getElementsByTagName(%22html%22)%5B0%5D.innerHTML)%7D)()">Click here</a>
Upvotes: 0
Reputation: 246
javascript: var temp = document.createElement("textarea");
document.body.appendChild(temp);
temp.value = document.getElementsByTagName("html")[0].innerHTML;
temp.select();
document.execCommand('copy');
temp.remove()
The code you are looking for is this where you select the text before executing "copy". But unfortunately even this wont work for you as all document.execCommand('copy') calls must take place as a direct result of a user action, e.g. click event handler. This is a measure to prevent messing with the users clipboard when they don't expect it. And according to my understanding of your post is that you are looking for a small script which you could paste in your address bar and copy the content. Check this for more details.
Upvotes: 0
Reputation: 3511
You should use clipboard.js
to get a workaround for this with cross browser compatibility.
Read more here
https://clipboardjs.com/
You can copy anything using
clipboard.copy("Your Content");
I added the stripped version of clipboard.js on top of your original js code. Then converted it to a JavaScript bookmarklet using https://mrcoles.com/bookmarklet/ and minified. Just add the following code as a link to the bookmarks bar of the browser and see the functionality or run the sample code.
<a href="javascript:(function()%7Bvar%20clipboard%3D%7B%7D%3Bclipboard.copy%3Dfunction()%7Bfunction%20t()%7Bn%3D!1%2Co%3Dnull%2Cr%26%26window.getSelection().removeAllRanges()%2Cr%3D!1%7Dfunction%20e()%7Bvar%20t%3Ddocument.getSelection()%3Bif(!document.queryCommandEnabled(%22copy%22)%26%26t.isCollapsed)%7Bvar%20e%3Ddocument.createRange()%3Be.selectNodeContents(document.body)%2Ct.removeAllRanges()%2Ct.addRange(e)%2Cr%3D!0%7D%7Dvar%20n%3D!1%2Co%3Dnull%2Cr%3D!1%3Breturn%20document.addEventListener(%22copy%22%2Cfunction(t)%7Bif(n)%7Bfor(var%20e%20in%20o)t.clipboardData.setData(e%2Co%5Be%5D)%3Bt.preventDefault()%7D%7D)%2Cfunction(r)%7Breturn%20new%20Promise(function(i%2Ca)%7Bfunction%20c(n)%7Btry%7Bif(document.execCommand(%22copy%22))t()%2Ci()%3Belse%7Bif(n)throw%20t()%2Cnew%20Error(%22Unable%20to%20copy.%20Perhaps%20it's%20not%20available%20in%20your%20browser%3F%22)%3Be()%2Cc(!0)%7D%7Dcatch(o)%7Bt()%2Ca(o)%7D%7Dn%3D!0%2C%22string%22%3D%3Dtypeof%20r%3Fo%3D%7B%22text%2Fplain%22%3Ar%7D%3Ar%20instanceof%20Node%3Fo%3D%7B%22text%2Fhtml%22%3A(new%20XMLSerializer).serializeToString(r)%7D%3Ar%20instanceof%20Object%3Fo%3Dr%3Aa(%22Invalid%20data%20type.%20Must%20be%20string%2C%20DOM%20node%2C%20or%20an%20object%20mapping%20MIME%20types%20to%20strings.%22)%2Cc(!1)%7D)%7D%7D()%2Cclipboard.paste%3Dfunction()%7Bvar%20t%2Ce%2Cn%3D!1%3Breturn%20document.addEventListener(%22paste%22%2Cfunction(o)%7Bif(n)%7Bn%3D!1%2Co.preventDefault()%3Bvar%20r%3Dt%3Bt%3Dnull%2Cr(o.clipboardData.getData(e))%7D%7D)%2Cfunction(o)%7Breturn%20new%20Promise(function(r%2Ci)%7Bn%3D!0%2Ct%3Dr%2Ce%3Do%7C%7C%22text%2Fplain%22%3Btry%7Bdocument.execCommand(%22paste%22)%7C%7C(n%3D!1%2Ci(new%20Error(%22Unable%20to%20paste.%20Pasting%20only%20works%20in%20Internet%20Explorer%20at%20the%20moment.%22)))%7Dcatch(a)%7Bn%3D!1%2Ci(new%20Error(a))%7D%7D)%7D%7D()%2C%22undefined%22%3D%3Dtypeof%20ClipboardEvent%26%26%22undefined%22!%3Dtypeof%20window.clipboardData%26%26%22undefined%22!%3Dtypeof%20window.clipboardData.setData%26%26(!function(t)%7Bfunction%20e(t%2Ce)%7Breturn%20function()%7Bt.apply(e%2Carguments)%7D%7Dfunction%20n(t)%7Bif(%22object%22!%3Dtypeof%20this)throw%20new%20TypeError(%22Promises%20must%20be%20constructed%20via%20new%22)%3Bif(%22function%22!%3Dtypeof%20t)throw%20new%20TypeError(%22not%20a%20function%22)%3Bthis._state%3Dnull%2Cthis._value%3Dnull%2Cthis._deferreds%3D%5B%5D%2Cu(t%2Ce(r%2Cthis)%2Ce(i%2Cthis))%7Dfunction%20o(t)%7Bvar%20e%3Dthis%3Breturn%20null%3D%3D%3Dthis._state%3Fvoid%20this._deferreds.push(t)%3Avoid%20s(function()%7Bvar%20n%3De._state%3Ft.onFulfilled%3At.onRejected%3Bif(null%3D%3D%3Dn)return%20void(e._state%3Ft.resolve%3At.reject)(e._value)%3Bvar%20o%3Btry%7Bo%3Dn(e._value)%7Dcatch(r)%7Breturn%20void%20t.reject(r)%7Dt.resolve(o)%7D)%7Dfunction%20r(t)%7Btry%7Bif(t%3D%3D%3Dthis)throw%20new%20TypeError(%22A%20promise%20cannot%20be%20resolved%20with%20itself.%22)%3Bif(t%26%26(%22object%22%3D%3Dtypeof%20t%7C%7C%22function%22%3D%3Dtypeof%20t))%7Bvar%20n%3Dt.then%3Bif(%22function%22%3D%3Dtypeof%20n)return%20void%20u(e(n%2Ct)%2Ce(r%2Cthis)%2Ce(i%2Cthis))%7Dthis._state%3D!0%2Cthis._value%3Dt%2Ca.call(this)%7Dcatch(o)%7Bi.call(this%2Co)%7D%7Dfunction%20i(t)%7Bthis._state%3D!1%2Cthis._value%3Dt%2Ca.call(this)%7Dfunction%20a()%7Bfor(var%20t%3D0%2Ce%3Dthis._deferreds.length%3Be%3Et%3Bt%2B%2B)o.call(this%2Cthis._deferreds%5Bt%5D)%3Bthis._deferreds%3Dnull%7Dfunction%20c(t%2Ce%2Cn%2Co)%7Bthis.onFulfilled%3D%22function%22%3D%3Dtypeof%20t%3Ft%3Anull%2Cthis.onRejected%3D%22function%22%3D%3Dtypeof%20e%3Fe%3Anull%2Cthis.resolve%3Dn%2Cthis.reject%3Do%7Dfunction%20u(t%2Ce%2Cn)%7Bvar%20o%3D!1%3Btry%7Bt(function(t)%7Bo%7C%7C(o%3D!0%2Ce(t))%7D%2Cfunction(t)%7Bo%7C%7C(o%3D!0%2Cn(t))%7D)%7Dcatch(r)%7Bif(o)return%3Bo%3D!0%2Cn(r)%7D%7Dvar%20s%3Dn.immediateFn%7C%7C%22function%22%3D%3Dtypeof%20setImmediate%26%26setImmediate%7C%7Cfunction(t)%7BsetTimeout(t%2C1)%7D%2Cl%3DArray.isArray%7C%7Cfunction(t)%7Breturn%22%5Bobject%20Array%5D%22%3D%3D%3DObject.prototype.toString.call(t)%7D%3Bn.prototype%5B%22catch%22%5D%3Dfunction(t)%7Breturn%20this.then(null%2Ct)%7D%2Cn.prototype.then%3Dfunction(t%2Ce)%7Bvar%20r%3Dthis%3Breturn%20new%20n(function(n%2Ci)%7Bo.call(r%2Cnew%20c(t%2Ce%2Cn%2Ci))%7D)%7D%2Cn.all%3Dfunction()%7Bvar%20t%3DArray.prototype.slice.call(1%3D%3D%3Darguments.length%26%26l(arguments%5B0%5D)%3Farguments%5B0%5D%3Aarguments)%3Breturn%20new%20n(function(e%2Cn)%7Bfunction%20o(i%2Ca)%7Btry%7Bif(a%26%26(%22object%22%3D%3Dtypeof%20a%7C%7C%22function%22%3D%3Dtypeof%20a))%7Bvar%20c%3Da.then%3Bif(%22function%22%3D%3Dtypeof%20c)return%20void%20c.call(a%2Cfunction(t)%7Bo(i%2Ct)%7D%2Cn)%7Dt%5Bi%5D%3Da%2C0%3D%3D%3D--r%26%26e(t)%7Dcatch(u)%7Bn(u)%7D%7Dif(0%3D%3D%3Dt.length)return%20e(%5B%5D)%3Bfor(var%20r%3Dt.length%2Ci%3D0%3Bi%3Ct.length%3Bi%2B%2B)o(i%2Ct%5Bi%5D)%7D)%7D%2Cn.resolve%3Dfunction(t)%7Breturn%20t%26%26%22object%22%3D%3Dtypeof%20t%26%26t.constructor%3D%3D%3Dn%3Ft%3Anew%20n(function(e)%7Be(t)%7D)%7D%2Cn.reject%3Dfunction(t)%7Breturn%20new%20n(function(e%2Cn)%7Bn(t)%7D)%7D%2Cn.race%3Dfunction(t)%7Breturn%20new%20n(function(e%2Cn)%7Bfor(var%20o%3D0%2Cr%3Dt.length%3Br%3Eo%3Bo%2B%2B)t%5Bo%5D.then(e%2Cn)%7D)%7D%2C%22undefined%22!%3Dtypeof%20module%26%26module.exports%3Fmodule.exports%3Dn%3At.Promise%7C%7C(t.Promise%3Dn)%7D(this)%2Cclipboard.copy%3Dfunction(t)%7Breturn%20new%20Promise(function(e%2Cn)%7Bif(%22string%22!%3Dtypeof%20t%26%26!(%22text%2Fplain%22in%20t))throw%20new%20Error(%22You%20must%20provide%20a%20text%2Fplain%20type.%22)%3Bvar%20o%3D%22string%22%3D%3Dtypeof%20t%3Ft%3At%5B%22text%2Fplain%22%5D%2Cr%3Dwindow.clipboardData.setData(%22Text%22%2Co)%3Br%3Fe()%3An(new%20Error(%22Copying%20was%20rejected.%22))%7D)%7D%2Cclipboard.paste%3Dfunction()%7Breturn%20new%20Promise(function(t%2Ce)%7Bvar%20n%3Dwindow.clipboardData.getData(%22Text%22)%3Bn%3Ft(n)%3Ae(new%20Error(%22Pasting%20was%20rejected.%22))%7D)%7D)%3Bclipboard.copy(document.getElementsByTagName(%22html%22)%5B0%5D.innerHTML)%3Balert(document.getElementsByTagName(%22html%22)%5B0%5D.innerHTML)%7D)()">Click here</a>
The required code is as below.
javascript:(function()%7Bvar%20clipboard%3D%7B%7D%3Bclipboard.copy%3Dfunction()%7Bfunction%20t()%7Bn%3D!1%2Co%3Dnull%2Cr%26%26window.getSelection().removeAllRanges()%2Cr%3D!1%7Dfunction%20e()%7Bvar%20t%3Ddocument.getSelection()%3Bif(!document.queryCommandEnabled(%22copy%22)%26%26t.isCollapsed)%7Bvar%20e%3Ddocument.createRange()%3Be.selectNodeContents(document.body)%2Ct.removeAllRanges()%2Ct.addRange(e)%2Cr%3D!0%7D%7Dvar%20n%3D!1%2Co%3Dnull%2Cr%3D!1%3Breturn%20document.addEventListener(%22copy%22%2Cfunction(t)%7Bif(n)%7Bfor(var%20e%20in%20o)t.clipboardData.setData(e%2Co%5Be%5D)%3Bt.preventDefault()%7D%7D)%2Cfunction(r)%7Breturn%20new%20Promise(function(i%2Ca)%7Bfunction%20c(n)%7Btry%7Bif(document.execCommand(%22copy%22))t()%2Ci()%3Belse%7Bif(n)throw%20t()%2Cnew%20Error(%22Unable%20to%20copy.%20Perhaps%20it's%20not%20available%20in%20your%20browser%3F%22)%3Be()%2Cc(!0)%7D%7Dcatch(o)%7Bt()%2Ca(o)%7D%7Dn%3D!0%2C%22string%22%3D%3Dtypeof%20r%3Fo%3D%7B%22text%2Fplain%22%3Ar%7D%3Ar%20instanceof%20Node%3Fo%3D%7B%22text%2Fhtml%22%3A(new%20XMLSerializer).serializeToString(r)%7D%3Ar%20instanceof%20Object%3Fo%3Dr%3Aa(%22Invalid%20data%20type.%20Must%20be%20string%2C%20DOM%20node%2C%20or%20an%20object%20mapping%20MIME%20types%20to%20strings.%22)%2Cc(!1)%7D)%7D%7D()%2Cclipboard.paste%3Dfunction()%7Bvar%20t%2Ce%2Cn%3D!1%3Breturn%20document.addEventListener(%22paste%22%2Cfunction(o)%7Bif(n)%7Bn%3D!1%2Co.preventDefault()%3Bvar%20r%3Dt%3Bt%3Dnull%2Cr(o.clipboardData.getData(e))%7D%7D)%2Cfunction(o)%7Breturn%20new%20Promise(function(r%2Ci)%7Bn%3D!0%2Ct%3Dr%2Ce%3Do%7C%7C%22text%2Fplain%22%3Btry%7Bdocument.execCommand(%22paste%22)%7C%7C(n%3D!1%2Ci(new%20Error(%22Unable%20to%20paste.%20Pasting%20only%20works%20in%20Internet%20Explorer%20at%20the%20moment.%22)))%7Dcatch(a)%7Bn%3D!1%2Ci(new%20Error(a))%7D%7D)%7D%7D()%2C%22undefined%22%3D%3Dtypeof%20ClipboardEvent%26%26%22undefined%22!%3Dtypeof%20window.clipboardData%26%26%22undefined%22!%3Dtypeof%20window.clipboardData.setData%26%26(!function(t)%7Bfunction%20e(t%2Ce)%7Breturn%20function()%7Bt.apply(e%2Carguments)%7D%7Dfunction%20n(t)%7Bif(%22object%22!%3Dtypeof%20this)throw%20new%20TypeError(%22Promises%20must%20be%20constructed%20via%20new%22)%3Bif(%22function%22!%3Dtypeof%20t)throw%20new%20TypeError(%22not%20a%20function%22)%3Bthis._state%3Dnull%2Cthis._value%3Dnull%2Cthis._deferreds%3D%5B%5D%2Cu(t%2Ce(r%2Cthis)%2Ce(i%2Cthis))%7Dfunction%20o(t)%7Bvar%20e%3Dthis%3Breturn%20null%3D%3D%3Dthis._state%3Fvoid%20this._deferreds.push(t)%3Avoid%20s(function()%7Bvar%20n%3De._state%3Ft.onFulfilled%3At.onRejected%3Bif(null%3D%3D%3Dn)return%20void(e._state%3Ft.resolve%3At.reject)(e._value)%3Bvar%20o%3Btry%7Bo%3Dn(e._value)%7Dcatch(r)%7Breturn%20void%20t.reject(r)%7Dt.resolve(o)%7D)%7Dfunction%20r(t)%7Btry%7Bif(t%3D%3D%3Dthis)throw%20new%20TypeError(%22A%20promise%20cannot%20be%20resolved%20with%20itself.%22)%3Bif(t%26%26(%22object%22%3D%3Dtypeof%20t%7C%7C%22function%22%3D%3Dtypeof%20t))%7Bvar%20n%3Dt.then%3Bif(%22function%22%3D%3Dtypeof%20n)return%20void%20u(e(n%2Ct)%2Ce(r%2Cthis)%2Ce(i%2Cthis))%7Dthis._state%3D!0%2Cthis._value%3Dt%2Ca.call(this)%7Dcatch(o)%7Bi.call(this%2Co)%7D%7Dfunction%20i(t)%7Bthis._state%3D!1%2Cthis._value%3Dt%2Ca.call(this)%7Dfunction%20a()%7Bfor(var%20t%3D0%2Ce%3Dthis._deferreds.length%3Be%3Et%3Bt%2B%2B)o.call(this%2Cthis._deferreds%5Bt%5D)%3Bthis._deferreds%3Dnull%7Dfunction%20c(t%2Ce%2Cn%2Co)%7Bthis.onFulfilled%3D%22function%22%3D%3Dtypeof%20t%3Ft%3Anull%2Cthis.onRejected%3D%22function%22%3D%3Dtypeof%20e%3Fe%3Anull%2Cthis.resolve%3Dn%2Cthis.reject%3Do%7Dfunction%20u(t%2Ce%2Cn)%7Bvar%20o%3D!1%3Btry%7Bt(function(t)%7Bo%7C%7C(o%3D!0%2Ce(t))%7D%2Cfunction(t)%7Bo%7C%7C(o%3D!0%2Cn(t))%7D)%7Dcatch(r)%7Bif(o)return%3Bo%3D!0%2Cn(r)%7D%7Dvar%20s%3Dn.immediateFn%7C%7C%22function%22%3D%3Dtypeof%20setImmediate%26%26setImmediate%7C%7Cfunction(t)%7BsetTimeout(t%2C1)%7D%2Cl%3DArray.isArray%7C%7Cfunction(t)%7Breturn%22%5Bobject%20Array%5D%22%3D%3D%3DObject.prototype.toString.call(t)%7D%3Bn.prototype%5B%22catch%22%5D%3Dfunction(t)%7Breturn%20this.then(null%2Ct)%7D%2Cn.prototype.then%3Dfunction(t%2Ce)%7Bvar%20r%3Dthis%3Breturn%20new%20n(function(n%2Ci)%7Bo.call(r%2Cnew%20c(t%2Ce%2Cn%2Ci))%7D)%7D%2Cn.all%3Dfunction()%7Bvar%20t%3DArray.prototype.slice.call(1%3D%3D%3Darguments.length%26%26l(arguments%5B0%5D)%3Farguments%5B0%5D%3Aarguments)%3Breturn%20new%20n(function(e%2Cn)%7Bfunction%20o(i%2Ca)%7Btry%7Bif(a%26%26(%22object%22%3D%3Dtypeof%20a%7C%7C%22function%22%3D%3Dtypeof%20a))%7Bvar%20c%3Da.then%3Bif(%22function%22%3D%3Dtypeof%20c)return%20void%20c.call(a%2Cfunction(t)%7Bo(i%2Ct)%7D%2Cn)%7Dt%5Bi%5D%3Da%2C0%3D%3D%3D--r%26%26e(t)%7Dcatch(u)%7Bn(u)%7D%7Dif(0%3D%3D%3Dt.length)return%20e(%5B%5D)%3Bfor(var%20r%3Dt.length%2Ci%3D0%3Bi%3Ct.length%3Bi%2B%2B)o(i%2Ct%5Bi%5D)%7D)%7D%2Cn.resolve%3Dfunction(t)%7Breturn%20t%26%26%22object%22%3D%3Dtypeof%20t%26%26t.constructor%3D%3D%3Dn%3Ft%3Anew%20n(function(e)%7Be(t)%7D)%7D%2Cn.reject%3Dfunction(t)%7Breturn%20new%20n(function(e%2Cn)%7Bn(t)%7D)%7D%2Cn.race%3Dfunction(t)%7Breturn%20new%20n(function(e%2Cn)%7Bfor(var%20o%3D0%2Cr%3Dt.length%3Br%3Eo%3Bo%2B%2B)t%5Bo%5D.then(e%2Cn)%7D)%7D%2C%22undefined%22!%3Dtypeof%20module%26%26module.exports%3Fmodule.exports%3Dn%3At.Promise%7C%7C(t.Promise%3Dn)%7D(this)%2Cclipboard.copy%3Dfunction(t)%7Breturn%20new%20Promise(function(e%2Cn)%7Bif(%22string%22!%3Dtypeof%20t%26%26!(%22text%2Fplain%22in%20t))throw%20new%20Error(%22You%20must%20provide%20a%20text%2Fplain%20type.%22)%3Bvar%20o%3D%22string%22%3D%3Dtypeof%20t%3Ft%3At%5B%22text%2Fplain%22%5D%2Cr%3Dwindow.clipboardData.setData(%22Text%22%2Co)%3Br%3Fe()%3An(new%20Error(%22Copying%20was%20rejected.%22))%7D)%7D%2Cclipboard.paste%3Dfunction()%7Breturn%20new%20Promise(function(t%2Ce)%7Bvar%20n%3Dwindow.clipboardData.getData(%22Text%22)%3Bn%3Ft(n)%3Ae(new%20Error(%22Pasting%20was%20rejected.%22))%7D)%7D)%3Bclipboard.copy(document.getElementsByTagName(%22html%22)%5B0%5D.innerHTML)%3Balert(document.getElementsByTagName(%22html%22)%5B0%5D.innerHTML)%7D)()
Upvotes: 2