From 233e37a1c8974dc630afa0a9f672f8911d32520d Mon Sep 17 00:00:00 2001 From: chylex Date: Sat, 3 Apr 2021 00:50:42 +0200 Subject: [PATCH] Release v.31 --- bld/track.js | 2 +- bld/track.user.js | 39 +++++++++++++++++++++++++++++++++------ bld/viewer.html | 16 +++++++++++----- build.py | 4 ++-- 4 files changed, 47 insertions(+), 14 deletions(-) diff --git a/bld/track.js b/bld/track.js index eba7719..3a9bcf1 100644 --- a/bld/track.js +++ b/bld/track.js @@ -1 +1 @@ -javascript:(function(){var e=function(){var n=function(){return t.s("messagesWrapper")},s=function(){return n().querySelector("[class*='scroller-']")},i=0,r=0;return{i:function(e){var a=function(){if(n()){let i=n().querySelector("[class*='message-']"),a=i?i.parentElement.children.length:0;a<100&&(r=0),r>0?(--r,o(750)):(a>300&&(r=6,t.o(()=>{let e=s();e.scrollTop=e.scrollHeight/2},1)),e(),o(200))}else o(500)},o=function(e){i=t.o(a,e)};a(),window.l.push(()=>window.clearInterval(i))},h:function(e){var t=Object.keys(e||{}),n=t.find(e=>e.startsWith("__reactInternalInstance"));return n?e[n].memoizedProps:(n=t.find(e=>e.startsWith("__reactProps$")),n?e[n]:null)},g:function(){try{var n,s=t.s("privateChannels");if(s){if(!((u=t.s("selected",s))&&"href"in u&&u.href.includes("/@me/")))return null;var i=u.href.split("/"),r=i[i.length-1];if(!/^\d+$/.test(r))return null;var a;for(let e of u.querySelectorAll("[class^='name-'] *")){let t=Array.prototype.find.call(e.childNodes,e=>e.nodeType===Node.TEXT_NODE);if(t){a=t.nodeValue;break}}if(!a)return null;var o=u.querySelector("img[class*='avatar']"),l=o&&o.closest("foreignObject"),c=l&&l.getAttribute("mask");n={server:a,channel:a,id:r,type:c&&c.includes("#svg-mask-avatar-default")?"GROUP":"DM",extra:{}}}else{var u=(s=document.getElementById("channels")).querySelector("[class*='modeSelected']").parentElement,d=e.h(u).children.props;if(!d)return null;var f=d.channel||d.children().props.channel;if(!f)return null;n={server:document.querySelector("nav header > h1").innerText,channel:f.name,id:f.id,type:"SERVER",extra:{position:f.position,topic:f.topic,nsfw:f.nsfw}}}return 0===n.channel.length?null:n}catch(e){return console.error(e),null}},p:function(){try{var t,n=s(),i=e.h(n);try{t=i.children.props.children.props.children.props.children.find(e=>Array.isArray(e))}catch(e){t=i.children.find(e=>Array.isArray(e))}var r=[];for(let e of t){let t=e.props;t&&t.message&&r.push(t.message)}return r}catch(e){return console.error(e),null}},v:()=>!!n(),S:function(){return null===document.querySelector("#messagesNavigationDescription + [class^=container]")},C:function(){let e=s();e.scrollTop>0&&(e.scrollTop=0)},T:function(){var e=t.s("privateChannels");if(e){var n=t.s("selected",e);return!!((l=n&&n.nextElementSibling)&&l.getAttribute("class").includes("channel-")&&"href"in l&&l.href.includes("/@me/"))&&(l.click(),l.scrollIntoView(!0),!0)}var s=e=>e.includes("wrapper-")&&!e.includes("clickable-"),i=e=>!!e.querySelector('path[d="M5.88657 21C5.57547 21 5.3399 20.7189 5.39427 20.4126L6.00001 17H2.59511C2.28449 17 2.04905 16.7198 2.10259 16.4138L2.27759 15.4138C2.31946 15.1746 2.52722 15 2.77011 15H6.35001L7.41001 9H4.00511C3.69449 9 3.45905 8.71977 3.51259 8.41381L3.68759 7.41381C3.72946 7.17456 3.93722 7 4.18011 7H7.76001L8.39677 3.41262C8.43914 3.17391 8.64664 3 8.88907 3H9.87344C10.1845 3 10.4201 3.28107 10.3657 3.58738L9.76001 7H15.76L16.3968 3.41262C16.4391 3.17391 16.6466 3 16.8891 3H17.8734C18.1845 3 18.4201 3.28107 18.3657 3.58738L17.76 7H21.1649C21.4755 7 21.711 7.28023 21.6574 7.58619L21.4824 8.58619C21.4406 8.82544 21.2328 9 20.9899 9H17.41L16.35 15H19.7549C20.0655 15 20.301 15.2802 20.2474 15.5862L20.0724 16.5862C20.0306 16.8254 19.8228 17 19.5799 17H16L15.3632 20.5874C15.3209 20.8261 15.1134 21 14.8709 21H13.8866C13.5755 21 13.3399 20.7189 13.3943 20.4126L14 17H8.00001L7.36325 20.5874C7.32088 20.8261 7.11337 21 6.87094 21H5.88657ZM9.41045 9L8.35045 15H14.3504L15.4104 9H9.41045Z"]')||!!e.querySelector('path[d="M14 8C14 7.44772 13.5523 7 13 7H9.76001L10.3657 3.58738C10.4201 3.28107 10.1845 3 9.87344 3H8.88907C8.64664 3 8.43914 3.17391 8.39677 3.41262L7.76001 7H4.18011C3.93722 7 3.72946 7.17456 3.68759 7.41381L3.51259 8.41381C3.45905 8.71977 3.69449 9 4.00511 9H7.41001L6.35001 15H2.77011C2.52722 15 2.31946 15.1746 2.27759 15.4138L2.10259 16.4138C2.04905 16.7198 2.28449 17 2.59511 17H6.00001L5.39427 20.4126C5.3399 20.7189 5.57547 21 5.88657 21H6.87094C7.11337 21 7.32088 20.8261 7.36325 20.5874L8.00001 17H14L13.3943 20.4126C13.3399 20.7189 13.5755 21 13.8866 21H14.8709C15.1134 21 15.3209 20.8261 15.3632 20.5874L16 17H19.5799C19.8228 17 20.0306 16.8254 20.0724 16.5862L20.2474 15.5862C20.301 15.2802 20.0655 15 19.7549 15H16.35L16.6758 13.1558C16.7823 12.5529 16.3186 12 15.7063 12C15.2286 12 14.8199 12.3429 14.7368 12.8133L14.3504 15H8.35045L9.41045 9H13C13.5523 9 14 8.55228 14 8Z"]'),r=e=>e.childElementCount>0&&s(e.children[0].className)&&i(e),a=document.querySelector("div[class*='sidebar'] > nav[class*='container'] > div[class*='scroller']");if(!a)return!1;for(var o=Array.prototype.filter.call(a.querySelectorAll("[class*='containerDefault']"),r),l=null,c=0;c{var i=document.createElement(e);i.id=n||"";i.innerHTML=s||"";t.appendChild(i);return i};return{id:(e,t)=>(t||document).getElementById(e),s:(e,t)=>(t||document).querySelector(`[class*="${e}-"]`),createElement:(t,n,s,i)=>e(t,n,s,i),O:e=>e.parentNode.removeChild(e),A:t=>e("style",document.head,"",t),o:(e,t)=>window.setTimeout(e,t),L:(e,t,n)=>e.addEventListener(t,n),k:(e,t,n)=>{var s=new Date(Date.now()+1e3*n).toUTCString();document.cookie=e+"="+encodeURIComponent(JSON.stringify(t))+";path=/;expires="+s},M:e=>{var t=document.cookie.replace(new RegExp("(?:(?:^|.*;\\s*)"+e+"\\s*\\=\\s*([^;]*).*$)|^.*$"),"$1");return t.length?JSON.parse(decodeURIComponent(t)):null},_:(t,n)=>{var s=new Blob([n],{type:"octet/stream"});if("msSaveBlob"in window.navigator)return window.navigator.msSaveBlob(s,t);var i=window.URL.createObjectURL(s);var r=e("a",document.body);r.href=i;r.download=t;r.style.display="none";r.click();document.body.removeChild(r);window.URL.revokeObjectURL(i)}}}(),n=function(){var e,n,r=()=>{o.N()?(e.H.U.disabled=!0,e.H.R.disabled=!0,e.H.D.disabled=!0):(e.H.U.disabled=!1,e.H.R.disabled=!1,e.H.I.disabled=e.H.D.disabled=!o.F())},l=(t,s)=>{if(e){var i="gui"===t&&"controller"===s;if(("data"===t||i)&&r(),("tracking"===t||i)&&(r(),e.H.q.innerHTML=o.N()?"Pause Tracking":"Start Tracking"),"data"===t||i){var l=0,c=0;o.F()&&(l=o.j().P(),c=o.j().W()),e.H.V.innerHTML=[l," message",1===l?"":"s"," from ",c," channel",1===c?"":"s"].join("")}}if(n&&((i="gui"===t&&"settings"===s)&&(n.H.G.checked=a.autoscroll,n.H.B[a.afterFirstMsg].checked=!0,n.H.J[a.afterSavedMsg].checked=!0),"setting"===t||i)){var u=!a.autoscroll;Object.values(n.H.B).forEach(e=>e.disabled=u),Object.values(n.H.J).forEach(e=>e.disabled=u)}},c=!1,u=function(e){c||(o.$(l),a.Z(l),c=!0),l("gui",e)},d={X:function(){(e={}).K=t.A(`\r\n#app-mount > div[class*="app-"] { margin-bottom: 48px !important; }\r\n#dht-ctrl { position: absolute; bottom: 0; width: 100%; height: 48px; background-color: #FFF; }\r\n#dht-ctrl button { height: 32px; margin: 8px 0 8px 8px; font-size: 16px; padding: 0 12px; background-color: #7289DA; color: #FFF; text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.75); }\r\n#dht-ctrl button:disabled { background-color: #7A7A7A; cursor: default; }\r\n#dht-ctrl-close { margin: 8px 8px 8px 0 !important; float: right; }\r\n#dht-ctrl p { display: inline-block; margin: 14px 12px; }\r\n#dht-ctrl input { display: none; }`);var n=(e,t)=>"";e.Y=t.createElement("div",document.body,"dht-ctrl",`\r\n${n("upload","Upload & Combine")}\r\n${n("settings","Settings")}\r\n${n("track","")}\r\n${n("download","Download")}\r\n${n("reset","Reset")}\r\n

\r\n\r\n${n("close","X")}`),e.H={U:t.id("dht-ctrl-upload"),R:t.id("dht-ctrl-settings"),q:t.id("dht-ctrl-track"),I:t.id("dht-ctrl-download"),D:t.id("dht-ctrl-reset"),ee:t.id("dht-ctrl-close"),V:t.id("dht-ctrl-status"),ne:t.id("dht-ctrl-upload-input")},t.L(e.H.U,"click",()=>{e.H.ne.click()}),t.L(e.H.R,"click",()=>{d.se()}),t.L(e.H.q,"click",()=>{o.ie(!o.N())}),t.L(e.H.I,"click",()=>{o.re()}),t.L(e.H.D,"click",()=>{o.ae()}),t.L(e.H.ee,"click",()=>{d.oe();window.l.forEach(e=>e());window.DHT_LOADED=!1}),t.L(e.H.ne,"change",()=>{Array.prototype.forEach.call(e.H.ne.files,e=>{var t=new FileReader;t.onload=function(){var n={};try{n=JSON.parse(t.result)}catch(t){return alert("Could not parse '"+e.name+"', see console for details."),void console.error(t)}s.le(n)?o.ce(e.name,new s(n)):alert("File '"+e.name+"' has an invalid format.")};t.readAsText(e,"UTF-8")});e.H.ne.value=null}),u("controller")},oe:function(){e&&(t.O(e.Y),t.O(e.K),e=null)},se:function(){(n={}).K=t.A(`\r\n#dht-cfg-overlay { position: absolute; left: 0; top: 0; width: 100%; height: 100%; background-color: #000; opacity: 0.5; display: block; z-index: 1000; }\r\n#dht-cfg { position: absolute; left: 50%; top: 50%; width: 800px; height: 262px; margin-left: -400px; margin-top: -131px; padding: 8px; background-color: #fff; z-index: 1001; }\r\n#dht-cfg-note { margin-top: 22px; }\r\n#dht-cfg sub { color: #666; font-size: 13px; }`),n.ue=t.createElement("div",document.body,"dht-cfg-overlay"),t.L(n.ue,"click",()=>{d.de()});var e=(e,t,n)=>"
";n.Y=t.createElement("div",document.body,"dht-cfg",`\r\n
\r\n
\r\n
\r\n${e("afm","nothing","Do Nothing")}\r\n${e("afm","pause","Pause Tracking")}\r\n${e("afm","switch","Switch to Next Channel")}\r\n
\r\n
\r\n${e("asm","nothing","Do Nothing")}\r\n${e("asm","pause","Pause Tracking")}\r\n${e("asm","switch","Switch to Next Channel")}\r\n

\r\nIt is recommended to disable link and image previews to avoid putting unnecessary strain on your browser.

\r\nv.30, released 28 Mar 2021\r\n

`),n.H={G:t.id("dht-cfg-autoscroll"),B:{},J:{}},n.H.B[i.fe]=t.id("dht-cfg-afm-nothing"),n.H.B[i.he]=t.id("dht-cfg-afm-pause"),n.H.B[i.ge]=t.id("dht-cfg-afm-switch"),n.H.J[i.fe]=t.id("dht-cfg-asm-nothing"),n.H.J[i.he]=t.id("dht-cfg-asm-pause"),n.H.J[i.ge]=t.id("dht-cfg-asm-switch"),n.H.G.addEventListener("change",()=>{a.autoscroll=n.H.G.checked}),Object.keys(n.H.B).forEach(e=>{t.L(n.H.B[e],"click",()=>{a.afterFirstMsg=e})}),Object.keys(n.H.J).forEach(e=>{t.L(n.H.J[e],"click",()=>{a.afterSavedMsg=e})}),u("settings")},de:function(){n&&(t.O(n.ue),t.O(n.Y),t.O(n.K),n=null)}};return d}();class s{constructor(e){var t=this;s.le(e)||(e={meta:{},data:{}}),t.meta=e.meta,t.data=e.data,t.meta.users=t.meta.users||{},t.meta.userindex=t.meta.userindex||[],t.meta.servers=t.meta.servers||[],t.meta.channels=t.meta.channels||{},t.me={pe:{},ve:new Set,Se:new Set,Ce:new Set}}static le(e){return e&&"object"==typeof e.meta&&"object"==typeof e.data}Te(e,t,n,s){var i=e in this.meta.users,r=i?this.meta.users[e]:{};return r.name=t,n&&(r.tag=n),s&&(r.avatar=s),i?e in this.me.pe?this.me.pe[e]:this.me.pe[e]=this.meta.userindex.findIndex(t=>t==e):(this.meta.users[e]=r,this.meta.userindex.push(e),this.me.pe[e]=this.meta.userindex.length-1)}ye(e,t){var n=this.meta.servers.findIndex(n=>n.name===e&&n.type===t);return-1===n?(this.meta.servers.push({name:e,type:t}),this.meta.servers.length-1):n}Oe(e,t,n,s){if(this.meta.servers[e]){var i=t in this.meta.channels,r=i?this.meta.channels[t]:{server:e};return r.name=n,s.position&&(r.position=s.position),s.topic&&(r.topic=s.topic),s.nsfw&&(r.nsfw=s.nsfw),!i&&(this.meta.channels[t]=r,this.me.ve.add(t),!0)}}Ae(e,t,n){var s=this.data[e]||(this.data[e]={}),i=t in s;return s[t]=n,this.me.Se.add(t),!i}we(e){var t=e.author,n={u:this.Te(t.id,t.username,t.bot?null:t.discriminator,t.avatar),t:e.timestamp.toDate().getTime()};return e.content.length>0&&(n.m=e.content),null!==e.editedTimestamp&&(n.te=e.editedTimestamp.toDate().getTime()),e.embeds.length>0&&(n.e=e.embeds.map(e=>{let t={url:e.url,type:e.type};"rich"===e.type&&Array.isArray(e.title)&&1===e.title.length&&"string"==typeof e.title[0]&&(t.t=e.title[0],Array.isArray(e.description)&&1===e.description.length&&"string"==typeof e.description[0]&&(t.d=e.description[0]));return t})),e.attachments.length>0&&(n.a=e.attachments.map(e=>({url:e.url}))),null!==e.messageReference&&(n.r=e.messageReference.message_id),n}be(e){return this.me.Ce.has(e)}Le(e,t){var n=!1;for(var s of t){var i=s.type;0!==i&&19!==i||"SENT"!==s.state||!this.Ae(e,s.id,this.we(s))||(this.me.Ce.add(s.id),n=!0)}return n}W(){return this.me.ve.size}P(){return this.me.Se.size}ke(e){var t={},n=!1;for(var s in e.meta.users){var i=e.meta.users[s];t[e.meta.userindex.findIndex(e=>e==s)]=this.Te(s,i.name,i.tag,i.avatar)}for(var r in e.meta.channels){var a=e.meta.servers[e.meta.channels[r].server],o=e.meta.channels[r];this.Oe(this.ye(a.name,a.type),r,o.name,o)}for(var r in e.data){o=e.data[r];for(var l in o){var c=o[l];(i=c.u)in t?(c.u=t[i],this.Ae(r,l,c)):(n||(n=!0,alert("The uploaded archive appears to be corrupted, some messages will be skipped. See console for details."),console.error("User list:",e.meta.users),console.error("User index:",e.meta.userindex),console.error("Generated mapping:",t),console.error("Missing user for the following messages:")),console.error(c))}}}Me(){return JSON.stringify({meta:this.meta,data:this.data})}}var i={fe:"optNothing",he:"optPause",ge:"optSwitch"},r=!1,a=function(){var e={},n=[],s=function(){t.k("DHT_SETTINGS",e,15768e4)},a=function(e,t){for(var i of n)i(e,t);s()},o=function(e,t,n){var s="_"+t;Object.defineProperty(e,t,{get:()=>e[s],set:n=>{e[s]=n;a("setting",t)}}),e[s]=n},l=t.M("DHT_SETTINGS");return l||(l={_autoscroll:!0,_afterFirstMsg:i.he,_afterSavedMsg:i.he},r=!0),o(e,"autoscroll",l._autoscroll),o(e,"afterFirstMsg",l._afterFirstMsg),o(e,"afterSavedMsg",l._afterSavedMsg),e.Z=function(e){n.push(e)},r&&s(),e}(),o=function(){var e=[],n=function(t,n){for(var s of e)s(t,n)};class i{constructor(){this.ae()}ae(){this._e=null,this.Ne=!1,this.Ue=null,n("data","reset")}j(){return this._e||(this._e=new s),this._e}F(){return null!=this._e}N(){return this.Ne}ie(e){this.Ne=e,n("tracking",e)}ce(e,t){this.Ue=e,this.j().ke(t),n("data","upload")}re(){this.F()&&t._(this.Ue||"dht.txt",this._e.Me())}He(e,t,s,i,r){var a=this.j().ye(e,t);!0===this.j().Oe(a,s,i,r)&&n("data","channel")}Re(e,t){return!!this.j().Le(e,t)&&(n("data","messages"),!0)}be(e){return this.j().be(e)}$(t){e.push(t)}}return new i}();const l=window.location.href;if(!l.includes("discord.com/")&&!l.includes("discordapp.com/")&&!confirm("Could not detect Discord in the URL, do you want to run the script anyway?"))return;if(window.DHT_LOADED)return void alert("Discord History Tracker is already loaded.");window.DHT_LOADED=!0,window.l=[];let c=new Set,u=null,d=function(e){c.add("stopping"),t.o(()=>{o.ie(!1);c.delete("stopping");e&&e()},200)};e.i(()=>{if(o.N()&&0===c.size){let n=e.g();if(!n)return void d();o.He(n.server,n.type,n.id,n.channel,n.extra);let s=e.p();if(null==s)return void d();if(!s.length)return void e.C();let r=o.Re(n.id,s);if(a.autoscroll){let l=null;r||o.be(s[0].id)?e.S()||(l=a.afterFirstMsg):l=a.afterSavedMsg,null===l?r?(e.C(),window.clearTimeout(u),u=null):u=window.setTimeout(e.C,2500):(c.add("stalling"),t.o(()=>{c.delete("stalling");let t=e.g();if(t&&t.id===n.id){let t=e.p();null!=t&&o.Re(n.id,t)}(l===i.ge&&!e.T()||l===i.he)&&o.ie(!1)},250))}}}),o.$((t,n)=>{if("tracking"===t&&n){let t=e.g();if(!t)return void d(()=>alert("The selected channel is not visible in the channel list."));{let n=e.p();if(null==n)return void d(()=>alert("Cannot see any messages."));o.He(t.server,t.type,t.id,t.channel,t.extra),o.Re(t.id,n)}if(a.autoscroll&&e.v())if(e.S())e.C();else{let t=a.afterFirstMsg;(t===i.ge&&!e.T()||t===i.he)&&d()}}}),n.X(),r&&n.se();})() \ No newline at end of file +javascript:(function(){var e=function(){var n=function(){return t.i("messagesWrapper")},i=function(){return n().querySelector("[class*='scroller-']")},s=0,r=0;return{s:function(e){var a=function(){if(n()){let s=n().querySelector("[class*='message-']"),a=s?s.parentElement.children.length:0;a<100&&(r=0),r>0?(--r,o(750)):(a>300&&(r=6,t.o(()=>{let e=i();e.scrollTop=e.scrollHeight/2},1)),e(),o(200))}else o(500)},o=function(e){s=t.o(a,e)};a(),window.l.push(()=>window.clearInterval(s))},h:function(e){var t=Object.keys(e||{}),n=t.find(e=>e.startsWith("__reactInternalInstance"));return n?e[n].memoizedProps:(n=t.find(e=>e.startsWith("__reactProps$")),n?e[n]:null)},g:function(){try{var n,i=t.i("privateChannels");if(i){if(!((u=t.i("selected",i))&&"href"in u&&u.href.includes("/@me/")))return null;var s=u.href.split("/"),r=s[s.length-1];if(!/^\d+$/.test(r))return null;var a;for(let e of u.querySelectorAll("[class^='name-'] *")){let t=Array.prototype.find.call(e.childNodes,e=>e.nodeType===Node.TEXT_NODE);if(t){a=t.nodeValue;break}}if(!a)return null;var o=u.querySelector("img[class*='avatar']"),l=o&&o.closest("foreignObject"),c=l&&l.getAttribute("mask");n={server:a,channel:a,id:r,type:c&&c.includes("#svg-mask-avatar-default")?"GROUP":"DM",extra:{}}}else{var u=(i=document.getElementById("channels")).querySelector("[class*='modeSelected']").parentElement,d=e.h(u).children.props;if(!d)return null;var f=d.channel||d.children().props.channel;if(!f)return null;n={server:document.querySelector("nav header > h1").innerText,channel:f.name,id:f.id,type:"SERVER",extra:{position:f.position,topic:f.topic,nsfw:f.nsfw}}}return 0===n.channel.length?null:n}catch(e){return console.error(e),null}},p:function(){try{var t,n=i(),s=e.h(n);try{t=s.children.props.children.props.children.props.children.find(e=>Array.isArray(e))}catch(e){t=s.children.find(e=>Array.isArray(e))}var r=[];for(let e of t){let t=e.props;t&&t.message&&r.push(t.message)}return r}catch(e){return console.error(e),null}},v:()=>!!n(),S:function(){return null===document.querySelector("#messagesNavigationDescription + [class^=container]")},C:function(){let e=i();e.scrollTop>0&&(e.scrollTop=0)},T:function(){var e=t.i("privateChannels");if(e){var n=t.i("selected",e);return!!((l=n&&n.nextElementSibling)&&l.getAttribute("class").includes("channel-")&&"href"in l&&l.href.includes("/@me/"))&&(l.click(),l.scrollIntoView(!0),!0)}var i=e=>e.includes("wrapper-")&&!e.includes("clickable-"),s=e=>!!e.querySelector('path[d="M5.88657 21C5.57547 21 5.3399 20.7189 5.39427 20.4126L6.00001 17H2.59511C2.28449 17 2.04905 16.7198 2.10259 16.4138L2.27759 15.4138C2.31946 15.1746 2.52722 15 2.77011 15H6.35001L7.41001 9H4.00511C3.69449 9 3.45905 8.71977 3.51259 8.41381L3.68759 7.41381C3.72946 7.17456 3.93722 7 4.18011 7H7.76001L8.39677 3.41262C8.43914 3.17391 8.64664 3 8.88907 3H9.87344C10.1845 3 10.4201 3.28107 10.3657 3.58738L9.76001 7H15.76L16.3968 3.41262C16.4391 3.17391 16.6466 3 16.8891 3H17.8734C18.1845 3 18.4201 3.28107 18.3657 3.58738L17.76 7H21.1649C21.4755 7 21.711 7.28023 21.6574 7.58619L21.4824 8.58619C21.4406 8.82544 21.2328 9 20.9899 9H17.41L16.35 15H19.7549C20.0655 15 20.301 15.2802 20.2474 15.5862L20.0724 16.5862C20.0306 16.8254 19.8228 17 19.5799 17H16L15.3632 20.5874C15.3209 20.8261 15.1134 21 14.8709 21H13.8866C13.5755 21 13.3399 20.7189 13.3943 20.4126L14 17H8.00001L7.36325 20.5874C7.32088 20.8261 7.11337 21 6.87094 21H5.88657ZM9.41045 9L8.35045 15H14.3504L15.4104 9H9.41045Z"]')||!!e.querySelector('path[d="M14 8C14 7.44772 13.5523 7 13 7H9.76001L10.3657 3.58738C10.4201 3.28107 10.1845 3 9.87344 3H8.88907C8.64664 3 8.43914 3.17391 8.39677 3.41262L7.76001 7H4.18011C3.93722 7 3.72946 7.17456 3.68759 7.41381L3.51259 8.41381C3.45905 8.71977 3.69449 9 4.00511 9H7.41001L6.35001 15H2.77011C2.52722 15 2.31946 15.1746 2.27759 15.4138L2.10259 16.4138C2.04905 16.7198 2.28449 17 2.59511 17H6.00001L5.39427 20.4126C5.3399 20.7189 5.57547 21 5.88657 21H6.87094C7.11337 21 7.32088 20.8261 7.36325 20.5874L8.00001 17H14L13.3943 20.4126C13.3399 20.7189 13.5755 21 13.8866 21H14.8709C15.1134 21 15.3209 20.8261 15.3632 20.5874L16 17H19.5799C19.8228 17 20.0306 16.8254 20.0724 16.5862L20.2474 15.5862C20.301 15.2802 20.0655 15 19.7549 15H16.35L16.6758 13.1558C16.7823 12.5529 16.3186 12 15.7063 12C15.2286 12 14.8199 12.3429 14.7368 12.8133L14.3504 15H8.35045L9.41045 9H13C13.5523 9 14 8.55228 14 8Z"]'),r=e=>e.childElementCount>0&&i(e.children[0].className)&&s(e),a=document.querySelector("div[class*='sidebar'] > nav[class*='container'] > div[class*='scroller']");if(!a)return!1;for(var o=Array.prototype.filter.call(a.querySelectorAll("[class*='containerDefault']"),r),l=null,c=0;c{var s=document.createElement(e);s.id=n||"";s.innerHTML=i||"";t.appendChild(s);return s};return{id:(e,t)=>(t||document).getElementById(e),i:(e,t)=>(t||document).querySelector(`[class*="${e}-"]`),createElement:(t,n,i,s)=>e(t,n,i,s),O:e=>e.parentNode.removeChild(e),A:t=>e("style",document.head,"",t),o:(e,t)=>window.setTimeout(e,t),L:(e,t,n)=>e.addEventListener(t,n),k:(e,t,n)=>{var i=new Date(Date.now()+1e3*n).toUTCString();document.cookie=e+"="+encodeURIComponent(JSON.stringify(t))+";path=/;expires="+i},M:e=>{var t=document.cookie.replace(new RegExp("(?:(?:^|.*;\\s*)"+e+"\\s*\\=\\s*([^;]*).*$)|^.*$"),"$1");return t.length?JSON.parse(decodeURIComponent(t)):null},_:(t,n)=>{var i=new Blob([n],{type:"octet/stream"});if("msSaveBlob"in window.navigator)return window.navigator.msSaveBlob(i,t);var s=window.URL.createObjectURL(i);var r=e("a",document.body);r.href=s;r.download=t;r.style.display="none";r.click();document.body.removeChild(r);window.URL.revokeObjectURL(s)}}}(),n=function(){var e,n,r=()=>{o.N()?(e.H.U.disabled=!0,e.H.R.disabled=!0,e.H.D.disabled=!0):(e.H.U.disabled=!1,e.H.R.disabled=!1,e.H.I.disabled=e.H.D.disabled=!o.F())},l=(t,i)=>{if(e){var s="gui"===t&&"controller"===i;if(("data"===t||s)&&r(),("tracking"===t||s)&&(r(),e.H.q.innerHTML=o.N()?"Pause Tracking":"Start Tracking"),"data"===t||s){var l=0,c=0;o.F()&&(l=o.j().P(),c=o.j().W()),e.H.V.innerHTML=[l," message",1===l?"":"s"," from ",c," channel",1===c?"":"s"].join("")}}if(n&&((s="gui"===t&&"settings"===i)&&(n.H.G.checked=a.autoscroll,n.H.B[a.afterFirstMsg].checked=!0,n.H.J[a.afterSavedMsg].checked=!0),"setting"===t||s)){var u=!a.autoscroll;Object.values(n.H.B).forEach(e=>e.disabled=u),Object.values(n.H.J).forEach(e=>e.disabled=u)}},c=!1,u=function(e){c||(o.$(l),a.Z(l),c=!0),l("gui",e)},d={X:function(){(e={}).K=t.A(`\r\n#app-mount > div[class*="app-"] { margin-bottom: 48px !important; }\r\n#dht-ctrl { position: absolute; bottom: 0; width: 100%; height: 48px; background-color: #FFF; }\r\n#dht-ctrl button { height: 32px; margin: 8px 0 8px 8px; font-size: 16px; padding: 0 12px; background-color: #7289DA; color: #FFF; text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.75); }\r\n#dht-ctrl button:disabled { background-color: #7A7A7A; cursor: default; }\r\n#dht-ctrl-close { margin: 8px 8px 8px 0 !important; float: right; }\r\n#dht-ctrl p { display: inline-block; margin: 14px 12px; }\r\n#dht-ctrl input { display: none; }`);var n=(e,t)=>"";e.Y=t.createElement("div",document.body,"dht-ctrl",`\r\n${n("upload","Upload & Combine")}\r\n${n("settings","Settings")}\r\n${n("track","")}\r\n${n("download","Download")}\r\n${n("reset","Reset")}\r\n

\r\n\r\n${n("close","X")}`),e.H={U:t.id("dht-ctrl-upload"),R:t.id("dht-ctrl-settings"),q:t.id("dht-ctrl-track"),I:t.id("dht-ctrl-download"),D:t.id("dht-ctrl-reset"),ee:t.id("dht-ctrl-close"),V:t.id("dht-ctrl-status"),ne:t.id("dht-ctrl-upload-input")},t.L(e.H.U,"click",()=>{e.H.ne.click()}),t.L(e.H.R,"click",()=>{d.ie()}),t.L(e.H.q,"click",()=>{o.se(!o.N())}),t.L(e.H.I,"click",()=>{o.ae()}),t.L(e.H.D,"click",()=>{o.oe()}),t.L(e.H.ee,"click",()=>{d.le();window.l.forEach(e=>e());window.DHT_LOADED=!1}),t.L(e.H.ne,"change",()=>{Array.prototype.forEach.call(e.H.ne.files,e=>{var t=new FileReader;t.onload=function(){var n={};try{n=JSON.parse(t.result)}catch(t){return alert("Could not parse '"+e.name+"', see console for details."),void console.error(t)}i.ce(n)?o.ue(e.name,new i(n)):alert("File '"+e.name+"' has an invalid format.")};t.readAsText(e,"UTF-8")});e.H.ne.value=null}),u("controller")},le:function(){e&&(t.O(e.Y),t.O(e.K),e=null)},ie:function(){(n={}).K=t.A(`\r\n#dht-cfg-overlay { position: absolute; left: 0; top: 0; width: 100%; height: 100%; background-color: #000; opacity: 0.5; display: block; z-index: 1000; }\r\n#dht-cfg { position: absolute; left: 50%; top: 50%; width: 800px; height: 262px; margin-left: -400px; margin-top: -131px; padding: 8px; background-color: #fff; z-index: 1001; }\r\n#dht-cfg-note { margin-top: 22px; }\r\n#dht-cfg sub { color: #666; font-size: 13px; }`),n.de=t.createElement("div",document.body,"dht-cfg-overlay"),t.L(n.de,"click",()=>{d.fe()});var e=(e,t,n)=>"
";n.Y=t.createElement("div",document.body,"dht-cfg",`\r\n
\r\n
\r\n
\r\n${e("afm","nothing","Do Nothing")}\r\n${e("afm","pause","Pause Tracking")}\r\n${e("afm","switch","Switch to Next Channel")}\r\n
\r\n
\r\n${e("asm","nothing","Do Nothing")}\r\n${e("asm","pause","Pause Tracking")}\r\n${e("asm","switch","Switch to Next Channel")}\r\n

\r\nIt is recommended to disable link and image previews to avoid putting unnecessary strain on your browser.

\r\nv.31, released 3 April 2021\r\n

`),n.H={G:t.id("dht-cfg-autoscroll"),B:{},J:{}},n.H.B[s.he]=t.id("dht-cfg-afm-nothing"),n.H.B[s.ge]=t.id("dht-cfg-afm-pause"),n.H.B[s.me]=t.id("dht-cfg-afm-switch"),n.H.J[s.he]=t.id("dht-cfg-asm-nothing"),n.H.J[s.ge]=t.id("dht-cfg-asm-pause"),n.H.J[s.me]=t.id("dht-cfg-asm-switch"),n.H.G.addEventListener("change",()=>{a.autoscroll=n.H.G.checked}),Object.keys(n.H.B).forEach(e=>{t.L(n.H.B[e],"click",()=>{a.afterFirstMsg=e})}),Object.keys(n.H.J).forEach(e=>{t.L(n.H.J[e],"click",()=>{a.afterSavedMsg=e})}),u("settings")},fe:function(){n&&(t.O(n.de),t.O(n.Y),t.O(n.K),n=null)}};return d}();class i{constructor(e){var t=this;i.ce(e)||(e={meta:{},data:{}}),t.meta=e.meta,t.data=e.data,t.meta.users=t.meta.users||{},t.meta.userindex=t.meta.userindex||[],t.meta.servers=t.meta.servers||[],t.meta.channels=t.meta.channels||{},t.pe={ve:{},Se:new Set,Ce:new Set,Te:new Set}}static ce(e){return e&&"object"==typeof e.meta&&"object"==typeof e.data}ye(e,t,n,i){var s=e in this.meta.users,r=s?this.meta.users[e]:{};return r.name=t,n&&(r.tag=n),i&&(r.avatar=i),s?e in this.pe.ve?this.pe.ve[e]:this.pe.ve[e]=this.meta.userindex.findIndex(t=>t==e):(this.meta.users[e]=r,this.meta.userindex.push(e),this.pe.ve[e]=this.meta.userindex.length-1)}Oe(e,t){var n=this.meta.servers.findIndex(n=>n.name===e&&n.type===t);return-1===n?(this.meta.servers.push({name:e,type:t}),this.meta.servers.length-1):n}Ae(e,t,n,i){if(this.meta.servers[e]){var s=t in this.meta.channels,r=s?this.meta.channels[t]:{server:e};return r.name=n,i.position&&(r.position=i.position),i.topic&&(r.topic=i.topic),i.nsfw&&(r.nsfw=i.nsfw),!s&&(this.meta.channels[t]=r,this.pe.Se.add(t),!0)}}we(e,t,n){var i=this.data[e]||(this.data[e]={}),s=t in i;return i[t]=n,this.pe.Ce.add(t),!s}be(e){var t=e.author,n={u:this.ye(t.id,t.username,t.bot?null:t.discriminator,t.avatar),t:e.timestamp.toDate().getTime()};return e.content.length>0&&(n.m=e.content),null!==e.editedTimestamp&&(n.te=e.editedTimestamp.toDate().getTime()),e.embeds.length>0&&(n.e=e.embeds.map(e=>{let t={url:e.url,type:e.type};"rich"===e.type&&Array.isArray(e.title)&&1===e.title.length&&"string"==typeof e.title[0]&&(t.t=e.title[0],Array.isArray(e.description)&&1===e.description.length&&"string"==typeof e.description[0]&&(t.d=e.description[0]));return t})),e.attachments.length>0&&(n.a=e.attachments.map(e=>({url:e.url}))),null!==e.messageReference&&(n.r=e.messageReference.message_id),e.reactions.length>0&&(n.re=e.reactions.map(e=>{let t={c:e.count,n:e.emoji.name};null!==e.emoji.id&&(t.id=e.emoji.id);e.emoji.animated&&(t.an=!0);return t})),n}Le(e){return this.pe.Te.has(e)}ke(e,t){var n=!1;for(var i of t){var s=i.type;0!==s&&19!==s||"SENT"!==i.state||!this.we(e,i.id,this.be(i))||(this.pe.Te.add(i.id),n=!0)}return n}W(){return this.pe.Se.size}P(){return this.pe.Ce.size}Me(e){var t={},n=!1;for(var i in e.meta.users){var s=e.meta.users[i];t[e.meta.userindex.findIndex(e=>e==i)]=this.ye(i,s.name,s.tag,s.avatar)}for(var r in e.meta.channels){var a=e.meta.servers[e.meta.channels[r].server],o=e.meta.channels[r];this.Ae(this.Oe(a.name,a.type),r,o.name,o)}for(var r in e.data){o=e.data[r];for(var l in o){var c=o[l];(s=c.u)in t?(c.u=t[s],this.we(r,l,c)):(n||(n=!0,alert("The uploaded archive appears to be corrupted, some messages will be skipped. See console for details."),console.error("User list:",e.meta.users),console.error("User index:",e.meta.userindex),console.error("Generated mapping:",t),console.error("Missing user for the following messages:")),console.error(c))}}}_e(){return JSON.stringify({meta:this.meta,data:this.data})}}var s={he:"optNothing",ge:"optPause",me:"optSwitch"},r=!1,a=function(){var e={},n=[],i=function(){t.k("DHT_SETTINGS",e,15768e4)},a=function(e,t){for(var s of n)s(e,t);i()},o=function(e,t,n){var i="_"+t;Object.defineProperty(e,t,{get:()=>e[i],set:n=>{e[i]=n;a("setting",t)}}),e[i]=n},l=t.M("DHT_SETTINGS");return l||(l={_autoscroll:!0,_afterFirstMsg:s.ge,_afterSavedMsg:s.ge},r=!0),o(e,"autoscroll",l._autoscroll),o(e,"afterFirstMsg",l._afterFirstMsg),o(e,"afterSavedMsg",l._afterSavedMsg),e.Z=function(e){n.push(e)},r&&i(),e}(),o=function(){var e=[],n=function(t,n){for(var i of e)i(t,n)};class s{constructor(){this.oe()}oe(){this.Ne=null,this.Ue=!1,this.He=null,n("data","reset")}j(){return this.Ne||(this.Ne=new i),this.Ne}F(){return null!=this.Ne}N(){return this.Ue}se(e){this.Ue=e,n("tracking",e)}ue(e,t){this.He=e,this.j().Me(t),n("data","upload")}ae(){this.F()&&t._(this.He||"dht.txt",this.Ne._e())}Re(e,t,i,s,r){var a=this.j().Oe(e,t);!0===this.j().Ae(a,i,s,r)&&n("data","channel")}Ee(e,t){return!!this.j().ke(e,t)&&(n("data","messages"),!0)}Le(e){return this.j().Le(e)}$(t){e.push(t)}}return new s}();const l=window.location.href;if(!l.includes("discord.com/")&&!l.includes("discordapp.com/")&&!confirm("Could not detect Discord in the URL, do you want to run the script anyway?"))return;if(window.DHT_LOADED)return void alert("Discord History Tracker is already loaded.");window.DHT_LOADED=!0,window.l=[];let c=new Set,u=null,d=function(e){c.add("stopping"),t.o(()=>{o.se(!1);c.delete("stopping");e&&e()},200)};e.s(()=>{if(o.N()&&0===c.size){let n=e.g();if(!n)return void d();o.Re(n.server,n.type,n.id,n.channel,n.extra);let i=e.p();if(null==i)return void d();if(!i.length)return void e.C();let r=o.Ee(n.id,i);if(a.autoscroll){let l=null;r||o.Le(i[0].id)?e.S()||(l=a.afterFirstMsg):l=a.afterSavedMsg,null===l?r?(e.C(),window.clearTimeout(u),u=null):u=window.setTimeout(e.C,2500):(c.add("stalling"),t.o(()=>{c.delete("stalling");let t=e.g();if(t&&t.id===n.id){let t=e.p();null!=t&&o.Ee(n.id,t)}(l===s.me&&!e.T()||l===s.ge)&&o.se(!1)},250))}}}),o.$((t,n)=>{if("tracking"===t&&n){let t=e.g();if(!t)return void d(()=>alert("The selected channel is not visible in the channel list."));{let n=e.p();if(null==n)return void d(()=>alert("Cannot see any messages."));o.Re(t.server,t.type,t.id,t.channel,t.extra),o.Ee(t.id,n)}if(a.autoscroll&&e.v())if(e.S())e.C();else{let t=a.afterFirstMsg;(t===s.me&&!e.T()||t===s.ge)&&d()}}}),n.X(),r&&n.ie();})() \ No newline at end of file diff --git a/bld/track.user.js b/bld/track.user.js index 820ec04..90e0488 100644 --- a/bld/track.user.js +++ b/bld/track.user.js @@ -1,6 +1,6 @@ // ==UserScript== // @name Discord History Tracker -// @version v.30 +// @version v.31 // @license MIT // @namespace https://chylex.com // @homepageURL https://dht.chylex.com/ @@ -594,7 +594,7 @@ ${radio("asm", "pause", "Pause Tracking")} ${radio("asm", "switch", "Switch to Next Channel")}

It is recommended to disable link and image previews to avoid putting unnecessary strain on your browser.

-v.30, released 28 Mar 2021 +v.31, released 3 April 2021

`); // elements @@ -691,8 +691,8 @@ It is recommended to disable link and image previews to avoid putting unnecessar * u: , * t: , * m: , // only present if not empty - * f: , // only present if edited in which case it equals 1, deprecated (use 'te' instead), - * te: , // only present if edited, + * f: , // only present if edited in which case it equals 1, deprecated (use 'te' instead) + * te: , // only present if edited * e: [ // omit for no embeds * { * url: , @@ -706,7 +706,15 @@ It is recommended to disable link and image previews to avoid putting unnecessar * url: * }, ... * ], - * r: // only present if referencing another message (reply) + * r: , // only present if referencing another message (reply) + * re: [ // omit for no reactions + * { + * c: + * n: , + * id: , // only present for custom emoji + * an: , // only present for custom animated emoji + * }, ... + * ] * }, ... * }, ... * } @@ -750,7 +758,7 @@ class SAVEFILE{ channelkeys: new Set(), messagekeys: new Set(), freshmsgs: new Set() - } + }; } static isValid(parsedObj){ @@ -888,6 +896,25 @@ class SAVEFILE{ obj.r = discordMessage.messageReference.message_id; } + if (discordMessage.reactions.length > 0) { + obj.re = discordMessage.reactions.map(reaction => { + let conv = { + c: reaction.count, + n: reaction.emoji.name + }; + + if (reaction.emoji.id !== null) { + conv.id = reaction.emoji.id; + } + + if (reaction.emoji.animated) { + conv.an = true; + } + + return conv; + }); + } + return obj; } diff --git a/bld/viewer.html b/bld/viewer.html index c84adcf..0f05b97 100644 --- a/bld/viewer.html +++ b/bld/viewer.html @@ -5,7 +5,7 @@ Discord Offline History +var e=function(){var e,n,a,i,s,o,l,u,d,f,p={i:/\*\*([\s\S]+?)\*\*(?!\*)/g,s:/(.)?\*([\s\S]+?)\*(?!\*)/g,o:/__([\s\S]+?)__(?!_)/g,l:/~~([\s\S]+?)~~(?!~)/g,p:/(`+)\s*([\s\S]*?[^`])\s*\1(?!`)/g,g:/```(?:([A-z0-9\-]+?)\n+)?\n*([^]+?)\n*```/g,v:/(\b(?:https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/gi,h:/<(\b(?:https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])>/gi,L:/\\`/g,C:/\\([*\\])/g,j:/\\__|_\\_|\\_\\_|\\~~|~\\~|\\~\\~/g,M:/([*_~\\])/g,U:/<@&(\d+?)>/g,k:/<@!?(\d+?)>/g,T:/<#(\d+?)>/g,R:/<:([^:]+):(\d+?)>/g,S:/<a:([^:]+):(\d+?)>/g},m=function(e){var t=e.url.lastIndexOf("."),n=-1===t?"":e.url.substring(t).toLowerCase();return".png"===n||".gif"===n||".jpg"===n||".jpeg"===n},g=function(e){var t=new Date(e);return t.toLocaleDateString()+", "+t.toLocaleTimeString()},v=function(e){var n=t.P(e.replace(p.h,"$1"));if(r.A.enableFormatting){var a=(e,t)=>"&#"+t.charCodeAt(0)+";";n=n.replace(p.L,"`").replace(p.g,(e,t,n)=>""+n.replace(p.M,a)+"").replace(p.p,(e,t,n)=>""+n.replace(p.M,a)+"").replace(p.C,a).replace(p.j,e=>e.replace(/\\/g,"").replace(/(.)/g,a)).replace(p.i,"$1").replace(p.s,(e,t,n)=>"\\"===t?e:(t||"")+""+n+"").replace(p.o,"$1").replace(p.l,"$1")}var i=r.A.enableAnimatedEmoji?"gif":"png";return"

"+(n=n.replace(p.v,"$1").replace(p.T,(e,t)=>"#"+r.O(t)+"").replace(p.k,(e,t)=>"@"+r.I(t)+"").replace(p.R,":$1:").replace(p.S,":$1:"))+"

"};return{N:function(){e=new c(["
","
#{name}{nsfw}{msgcount}
","{server.name} ({server.type})","
"].join("")),n=new c(["
","
{name}{msgcount}
","({server.type})","
"].join("")),a=new c(["
","
{reply}
","

{user.name}{timestamp}{edit}{jump}

","
{contents}{embeds}{attachments}
","
{reactions}
","
"].join("")),i=new c(["
","
{reply}
","
","
{avatar}
","
","

{user.name}{timestamp}{edit}{jump}

","
{contents}{embeds}{attachments}
","
{reactions}
","
","
","
"].join("")),s=new c([""].join("")),o=new c(["(image attachment not found)
"].join("")),l=new c(["
{t}

{d}

"].join("")),u=new c([""].join("")),d=new c(["

(Formatted embeds are currently not supported)

"].join("")),f=new c(["Download {filename}"].join("")),templateReaction=new c(["{n}{c}"].join("")),templateReactionCustom=new c([":{n}:{c}"].join(""))},B:m,H:function(t){return("SERVER"===t.server.type?e:n).apply(t,(e,t)=>{if("server.type"===e)switch(t){case"SERVER":return"server";case"GROUP":return"group";case"DM":return"user"}else if("nsfw"===e)return t?"NSFW":""})},_:function(e){return(r.A.enableUserAvatars?i:a).apply(e,(e,t)=>{if("avatar"===e)return t?s.apply(t):"";if("user.tag"===e)return t||"????";if("timestamp"===e)return g(t);if("contents"===e)return null==t||0===t.length?"":v(t);if("embeds"===e)return t?t.map(e=>{switch(e.type){case"image":return r.A.enableImagePreviews?o.apply(e):"";case"rich":return(e.t?e.d?l:u:d).apply(e)}}).join(""):"";if("attachments"===e)return t?t.map(e=>{if(m(e)&&r.A.enableImagePreviews)return o.apply(e);var t=e.url.split("/");return f.apply({url:e.url,filename:t[t.length-1]})}).join(""):"";if("edit"===e)return t?"Edited"+(t>1?" "+g(t):"")+"":"";if("jump"===e)return r.D?"Jump to message":"";if("reply"===e){if(null===t)return"";var n=""+t.user.name+"",a=r.A.enableUserAvatars&&t.avatar?""+s.apply(t.avatar)+"":"",i=t.contents?""+v(t.contents)+"":"";return"Jump to reply"+a+n+""+i}if("reactions"===e)return null===t?"":t.map(e=>"id"in e?(e.ext=e.an&&r.A.enableAnimatedEmoji?"gif":"png",templateReactionCustom.apply(e)):templateReaction.apply(e)).join("")})}}}(),t=function(){var e=(e,t)=>{var n=document.createElement(e);t.appendChild(n);return n},t={"&":"&","<":"<",">":">",'"':""","'":"'"},n=/[&<>"']/g;return{id:(e,t)=>(t||document).getElementById(e),$:(e,t)=>Array.prototype.slice.call((t||document).getElementsByClassName(e)),tag:(e,t)=>Array.prototype.slice.call((t||document).getElementsByTagName(e)),J:(e,t)=>(t||document).getElementsByClassName(e)[0],createElement:(t,n)=>e(t,n),V:e=>e.parentNode.removeChild(e),P:e=>String(e).replace(n,e=>t[e]),Z:(t,n)=>{var a=new Blob([n],{type:"octet/stream"});if("msSaveBlob"in window.navigator)return window.navigator.msSaveBlob(a,t);var i=window.URL.createObjectURL(a);var s=e("a",document.body);s.href=i;s.download=t;s.style.display="none";s.click();document.body.removeChild(s);window.URL.revokeObjectURL(i)}}}(),n=function(){var e,n,a=!1,i=function(e,n){var a=new Blob([n],{type:"octet/stream"});if("msSaveBlob"in window.navigator)return window.navigator.msSaveBlob(a,e);var i=window.URL.createObjectURL(a),s=t.createElement("a",document.body);s.href=i,s.download=e,s.style.display="none",s.click(),document.body.removeChild(s),window.URL.revokeObjectURL(i)},s=function(e){return window.btoa(unescape(encodeURIComponent(e)))},r=function(e){return decodeURIComponent(escape(window.atob(e)))};return{N:function(){a=!0,e="\n"+document.documentElement.outerHTML,t.id("btn-upload-file").insertAdjacentHTML("afterend",``),t.id("btn-embed-file").addEventListener("click",()=>i("embed.html",n))},q:function(i){a&&(t.id("btn-embed-file").disabled=!1,n=e.replace("",`\n