discord-transcript-ui 1.0.1 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +35 -1
- package/dist/discord-transcript.css +7 -2
- package/dist/discord-transcript.js +67 -29
- package/dist/discord-transcript.min.css +2 -2
- package/dist/discord-transcript.min.js +2 -2
- package/dist/discord-transcript.short.css +1947 -0
- package/dist/discord-transcript.short.min.css +2 -0
- package/dist/manifest.json +60 -37
- package/dist/recovery-comment.txt +16 -16
- package/dist/{v1.0.1 → v1.1.1}/discord-transcript.css +7 -2
- package/dist/{v1.0.1 → v1.1.1}/discord-transcript.js +67 -29
- package/dist/v1.1.1/discord-transcript.min.css +2 -0
- package/dist/v1.1.1/discord-transcript.min.js +2 -0
- package/dist/v1.1.1/discord-transcript.short.css +1947 -0
- package/dist/v1.1.1/discord-transcript.short.min.css +2 -0
- package/package.json +1 -1
- package/src/discord-transcript.css +7 -2
- package/src/discord-transcript.js +67 -29
- package/dist/v1.0.1/discord-transcript.min.css +0 -2
- package/dist/v1.0.1/discord-transcript.min.js +0 -2
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! discord-transcript-ui v1.1.1 | MIT | https://github.com/x1xo/discord-transcript-ui */
|
|
2
|
+
(function(){"use strict";if(typeof window=="undefined"||typeof document=="undefined"||window.DiscordTranscript&&window.DiscordTranscript.version)return;var J="1.0.0",Tt=420*1e3,E={blue:"https://cdn.discordapp.com/embed/avatars/0.png",gray:"https://cdn.discordapp.com/embed/avatars/1.png",green:"https://cdn.discordapp.com/embed/avatars/2.png",orange:"https://cdn.discordapp.com/embed/avatars/3.png",red:"https://cdn.discordapp.com/embed/avatars/4.png",pink:"https://cdn.discordapp.com/embed/avatars/5.png"},z=["#5865f2","#3ba55c","#faa81a","#ed4245","#eb459e","#00a8fc","#9b59b6","#1abc9c"],Q=[],w=[],X={messages:"dms",message:"dm",reply:"drp",time:"dti",spoiler:"dsp",embed:"de","embed-footer":"defo","file-attachment":"dfil","image-attachment":"dimg","video-attachment":"dvid","audio-attachment":"daud",reaction:"dr",pre:"dp",code:"dc","custom-emoji":"demo",attachments:"dats",thread:"dth","author-info":"dai"};function s(t){var r=X[t];return r?":is(discord-"+t+","+r+")":"discord-"+t}function P(){return window.$discordMessage=window.$discordMessage||{}}function q(){return window.discordTranscript=window.discordTranscript||{}}function K(){var t={},r;for(r in E)t[r]=E[r];var e=P().avatars||{};for(r in e)e[r]&&(t[r]=e[r]);return(!t.default||E[t.default])&&(t.default=t[e.default]||E.blue),t}function tt(t){var r=K();return t==null||t===""?r.default:r[t]?r[t]:t}function rt(t){var r=t.getAttribute("profile"),e=P().profiles||{};return r&&e[r]||{}}function et(t,r,e){var a=t.getAttribute(r);return a===null||a===""?e:a}function at(t){var r=rt(t),e=et(t,"author",r.author||"User"),a=t.getAttribute("avatar")||r.avatar;return{author:e,avatarUrl:tt(a),hasAvatar:!!a,roleColor:t.getAttribute("role-color")||r.roleColor||null,bot:c(t,"bot")||!!r.bot,verified:c(t,"verified")||!!r.verified,server:c(t,"server")||!!r.server,official:c(t,"official-app")||!!r.officialApp,op:c(t,"op")||!!r.op}}function c(t,r){return t.hasAttribute(r)}function it(t){for(var r=0,e=0;e<t.length;e++)r=(r+t.charCodeAt(e))%997;return z[r%z.length]}function T(t){if(t==null||t==="")return null;if(/^\d+$/.test(t))return new Date(Number(t));var r=new Date(t);return isNaN(r.getTime())?null:r}function dt(){return q().timeZone||void 0}function nt(){return q().locale||"en-US"}function D(t,r){return new Intl.DateTimeFormat(nt(),Object.assign({timeZone:dt()},t)).format(r)}function L(t){return!(t||q().hour24)}function x(t,r){return D({hour:"numeric",minute:"2-digit",hour12:L(r)},t).replace(/\u202f/g," ")}function N(t,r){return x(t,r).replace(/\s+(AM|PM)$/i,"$1")}function R(t){return D({year:"2-digit",month:"numeric",day:"numeric"},t)}function B(t,r){return R(t)+", "+x(t,r)}function ot(t,r){var e=new Date,a=new Date(e.getFullYear(),e.getMonth(),e.getDate()),i=new Date(t.getFullYear(),t.getMonth(),t.getDate()),d=Math.round((a-i)/864e5);return d===0?N(t,r):d===1?"Yesterday at "+N(t,r):B(t,r)}function F(t,r,e){switch(r){case"t":return x(t,e);case"T":return D({hour:"numeric",minute:"2-digit",second:"2-digit",hour12:L(e)},t).replace(/\u202f/g," ");case"d":return R(t);case"D":return D({day:"numeric",month:"long",year:"numeric"},t);case"F":return D({weekday:"long",day:"numeric",month:"long",year:"numeric"},t)+" at "+x(t,e);case"R":return U(t);case"s":return B(t,e);case"S":return R(t)+", "+D({hour:"numeric",minute:"2-digit",second:"2-digit",hour12:L(e)},t).replace(/\u202f/g," ");case"f":default:return B(t,e)}}function U(t){for(var r=Math.round((t.getTime()-Date.now())/1e3),e=r>0,a=[["year",31536e3],["month",2592e3],["week",604800],["day",86400],["hour",3600],["minute",60],["second",1]],i=0;i<a.length;i++){var d=a[i][1];if(Math.abs(r)>=d||d===1){var o=Math.abs(Math.round(r/d)),u=a[i][0]+(o===1?"":"s");return e?"in "+o+" "+u:o+" "+u+" ago"}}return"now"}function n(t,r,e){var a=document.createElement(t);return r&&(a.className=r),e!==void 0&&(a.textContent=e),a}function $(t,r){var e=n("span",r||"dt-avatar");if(t.hasAvatar){var a=n("img");a.src=t.avatarUrl,a.alt="",a.decoding="async",e.appendChild(a)}else e.classList.add("dt-avatar--initials"),e.style.backgroundColor=it(t.author),e.textContent=(t.author||"?").charAt(0);return e}function ut(t){var r=n("span","dt-badges");if(t.bot){var e=t.verified?"dt-badge dt-badge--verified":"dt-badge";r.appendChild(n("span",e,"APP"))}else t.server?r.appendChild(n("span","dt-badge dt-badge--server","SERVER")):t.official&&r.appendChild(n("span","dt-badge dt-badge--official","OFFICIAL"));return t.op&&r.appendChild(n("span","dt-badge","OP")),r.children.length?r:null}function st(t){if(!c(t,"data-dt-ready")){var r=W(t),e=T(t.getAttribute("timestamp")),a=n("div","dt-body"),i=[],d=t.querySelector(":scope > "+s("author-info")+", :scope > discord-message-header");for(d&&d.remove();t.firstChild;){var o=t.firstChild;if(o.nodeType===1&&(o.tagName==="DISCORD-REPLY"||o.tagName==="DISCORD-COMMAND")){i.push(o),t.removeChild(o);continue}a.appendChild(o)}var u=n("div","dt-msg");if(i.length){u.classList.add("dt-msg--has-reply");for(var f=0;f<i.length;f++)u.appendChild(i[f])}u.appendChild($(r,"dt-avatar"));var l=n("div","dt-content"),p=n("div","dt-header"),g=n("span","dt-author",r.author);r.roleColor&&(g.style.color=r.roleColor),p.appendChild(g);var v=ut(r);v&&p.appendChild(v);var h=c(t,"twenty-four");if(e){var y=n("span","dt-timestamp",ot(e,h));y.title=F(e,"F",h),p.appendChild(y),t.setAttribute("data-dt-short-time",x(e,h))}l.appendChild(p),l.appendChild(a),u.appendChild(l),t.appendChild(u),c(t,"edited")&&a.appendChild(n("span","dt-edited","(edited)")),ct(a)&&a.classList.add("dt-jumbo"),t.setAttribute("data-dt-ready","")}}function W(t){return at(t)}function ct(t){var r=(t.textContent||"").replace(/\s+/g,"");if(r.length>0)return!1;var e=t.querySelectorAll(s("custom-emoji")+", img.emoji");return e.length>0&&e.length<=6}function lt(t){if(q().grouping!==!1)for(var r=(q().groupWindow||7)*60*1e3,e=null,a=null,i=0;i<t.length;i++){var d=t[i];if(d.removeAttribute("data-dt-continuation"),d.removeAttribute("data-dt-group-start"),d.hasAttribute("message-body-only")){d.setAttribute("data-dt-continuation",""),e=null,a=null;continue}var o=d.getAttribute("profile")||d.getAttribute("author")||d.getAttribute("avatar"),u=T(d.getAttribute("timestamp")),f=e!==null&&o!==null&&o===e,l=a===null||u===null||Math.abs(u-a)<=r;f&&l?d.setAttribute("data-dt-continuation",""):e!==null&&d.setAttribute("data-dt-group-start",""),e=o,a=u}}function ft(t){if(!(c(t,"data-dt-ready")||c(t,"deleted"))){var r=W(t),e=[];t.querySelector(":scope > .dt-reply-avatar")||r.hasAvatar&&e.push($(r,"dt-reply-avatar"));var a=n("span","dt-reply-author",(c(t,"mentions")?"@":"")+r.author);r.roleColor&&(a.style.color=r.roleColor),e.push(a);var i=n("span","dt-sr-only","replying to ");t.insertBefore(i,t.firstChild);for(var d=e.length-1;d>=0;d--)t.insertBefore(e[d],i.nextSibling);t.setAttribute("data-dt-ready","")}}function pt(t){if(!c(t,"data-dt-ready")){var r=t.getAttribute("timestamp");if(r){var e=T(r==="now"?String(Date.now()):r);if(e){var a=c(t,"twenty-four"),i=t.getAttribute("format")||"f";t.setAttribute("data-dt-stamp",e.toISOString()),t.textContent=F(e,i,a),t.setAttribute("datetime",e.toISOString()),t.title=F(e,"F",a),t.setAttribute("data-dt-ready",""),i==="R"&&w.indexOf(t)===-1&&w.push(t)}}}}function vt(t){return T(t.getAttribute("data-dt-stamp")||t.getAttribute("timestamp"))}function Y(){for(var t=0;t<w.length;t++){var r=vt(w[t]);r&&(w[t].textContent=U(r))}}function gt(t){for(var r=t.querySelectorAll(s("spoiler")+":not([data-dt-ready])"),e=0;e<r.length;e++){var a=r[e];a.setAttribute("data-dt-ready",""),a.setAttribute("role","button"),a.hasAttribute("tabindex")||a.setAttribute("tabindex","0"),a.setAttribute("aria-expanded",c(a,"activated")?"true":"false")}for(var i=t.querySelectorAll(s("image-attachment")+"[spoiler], "+s("video-attachment")+"[spoiler]"),d=0;d<i.length;d++)i[d].querySelector(":scope > .dt-spoiler-overlay")||i[d].appendChild(n("button","dt-spoiler-overlay","Spoiler"))}function G(t){var r=!c(t,"data-dt-revealed");r?t.setAttribute("data-dt-revealed",""):t.removeAttribute("data-dt-revealed"),t.hasAttribute("aria-expanded")&&t.setAttribute("aria-expanded",r?"true":"false")}function ht(t){if(!c(t,"data-dt-ready")){var r=t.getAttribute("emoji"),e=r&&/^(https?:|data:|blob:|\/|\.\/)/i.test(r);if(e){var a=n("img","dt-reaction-emoji");a.src=r,a.alt=t.getAttribute("name")||"",a.loading="lazy",a.decoding="async",t.appendChild(a)}else r&&t.appendChild(n("span","dt-reaction-emoji",r));var i=parseInt(t.getAttribute("count")||"1",10);i>1&&t.appendChild(n("span","dt-reaction-count",String(i))),t.setAttribute("data-dt-ready","")}}function bt(t){var r=t.querySelector(":scope > .dt-reaction-count");return r&&parseInt(r.textContent,10)||1}function H(t,r){var e=t.querySelector(":scope > .dt-reaction-count");if(r<=1){e&&e.remove();return}e?e.textContent=String(r):t.appendChild(n("span","dt-reaction-count",String(r)))}function yt(t){if(!c(t,"data-dt-ready")){var r=t.getAttribute("color");r&&t.style.setProperty("--dt-embed-color",r);var e=t.querySelector(":scope > .dt-embed-content");if(!e){for(e=n("div","dt-embed-content");t.firstChild;)e.appendChild(t.firstChild);t.appendChild(e)}var a=t.getAttribute("provider");a&&!e.querySelector(":scope > .dt-embed-provider")&&e.insertBefore(n("span","dt-embed-provider",a),e.firstChild);var i=t.getAttribute("author-name");if(i&&!e.querySelector(":scope > .dt-embed-author")){var d=n("div","dt-embed-author"),o=t.getAttribute("author-image");if(o){var u=n("img");u.src=o,u.alt="",u.loading="lazy",u.decoding="async",d.appendChild(u)}var f=t.getAttribute("author-url");if(f){var l=n("a",null,i);l.href=f,l.target="_blank",l.rel="noopener noreferrer",d.appendChild(l)}else d.appendChild(n("span",null,i));e.insertBefore(d,e.firstChild)}var p=t.getAttribute("embed-title")||t.getAttribute("title");if(p&&!e.querySelector(":scope > .dt-embed-title")){var g=t.getAttribute("url"),v=g?n("a","dt-embed-title dt-embed-title--link",p):n("span","dt-embed-title",p);g&&(v.href=g,v.target="_blank",v.rel="noopener noreferrer");var h=e.querySelector(":scope > .dt-embed-author, :scope > .dt-embed-provider");h?h.insertAdjacentElement("afterend",v):e.insertBefore(v,e.firstChild)}var y=t.getAttribute("thumbnail");if(y&&!t.querySelector(":scope > .dt-embed-thumbnail")){var M=n("div","dt-embed-thumbnail"),A=n("img");A.src=y,A.alt="",A.loading="lazy",A.decoding="async",M.appendChild(A),t.appendChild(M)}var C=t.getAttribute("video"),O=t.getAttribute("image");if((C||O)&&!t.querySelector(":scope > .dt-embed-image")){var m=n("div","dt-embed-image");if(C){var S=n("video");S.controls=!0,S.preload="metadata",S.src=C,m.appendChild(S)}else{var b=n("img");b.src=O,b.alt="",b.loading="lazy",b.decoding="async",m.appendChild(b)}var I=e.querySelector(":scope > "+s("embed-footer"));e.insertBefore(m,I||null)}t.setAttribute("data-dt-ready","")}}function At(t){if(!c(t,"data-dt-ready")){var r=t.getAttribute("url");if(r&&!t.querySelector("img")){var e=n("img");e.src=r,e.alt=t.getAttribute("alt")||"discord image attachment",e.loading="lazy",e.decoding="async";var a=t.getAttribute("width"),i=t.getAttribute("height");a&&(e.style.maxWidth=a+"px"),i&&(e.style.maxHeight=i+"px"),t.appendChild(e)}var d=t.querySelector("img");d&&!d.getAttribute("loading")&&(d.loading="lazy"),t.setAttribute("data-dt-ready","")}}function V(t,r){if(!c(t,"data-dt-ready")){var e=t.getAttribute("href")||t.getAttribute("src");if(e&&!t.querySelector(r)){var a=n(r);if(a.controls=!0,a.preload="metadata",a.src=e,r==="video"){a.playsInline=!0;var i=t.getAttribute("poster");i&&(a.poster=i)}t.appendChild(a)}t.setAttribute("data-dt-ready","")}}function Ct(t){if(!c(t,"data-dt-ready")){var r=t.getAttribute("href");if(r&&!t.firstChild){var e=n("a");e.href=r,e.target=t.getAttribute("target")||"_blank",e.rel="noopener noreferrer";var a=t.getAttribute("name")||r.split("/").pop()||"file";e.appendChild(n("span","dt-file-icon",t.getAttribute("type")||"FILE"));var i=n("span","dt-file-meta");i.appendChild(n("span","dt-file-name",a)),i.appendChild(n("span","dt-file-size",[t.getAttribute("bytes"),t.getAttribute("bytes-unit")].filter(Boolean).join(" "))),e.appendChild(i),t.appendChild(e)}t.setAttribute("data-dt-ready","")}}function mt(t){if(!(c(t,"data-dt-ready")||t.querySelector(":scope > .dt-copy"))){var r=n("button","dt-copy","Copy");r.type="button",t.appendChild(r),t.setAttribute("data-dt-ready","")}}function St(t){for(var r=t.querySelectorAll(s("attachments")+" img:not([loading]), "+s("embed")+" img:not([loading]), "+s("embed")+" video, "+s("thread")+" img"),e=0;e<r.length;e++)r[e].setAttribute("loading","lazy")}function k(t){if(!(!t||!t.querySelectorAll)){for(var r=t.querySelectorAll(s("message")+":not([data-dt-ready])"),e=0;e<r.length;e++)st(r[e]);for(var a=t.querySelectorAll(s("messages")),i=0;i<a.length;i++){var d=a[i].querySelectorAll(":scope > "+s("message"));d.length&<(d)}for(var o=t.querySelectorAll(s("reply")+":not([data-dt-ready])"),u=0;u<o.length;u++)ft(o[u]);for(var f=t.querySelectorAll(s("time")+":not([data-dt-ready])"),l=0;l<f.length;l++)pt(f[l]);for(var p=t.querySelectorAll(s("embed")+":not([data-dt-ready])"),g=0;g<p.length;g++)yt(p[g]);for(var v=t.querySelectorAll(s("file-attachment")+":not([data-dt-ready])"),h=0;h<v.length;h++)Ct(v[h]);for(var y=t.querySelectorAll(s("image-attachment")+":not([data-dt-ready])"),M=0;M<y.length;M++)At(y[M]);for(var A=t.querySelectorAll(s("video-attachment")+":not([data-dt-ready])"),C=0;C<A.length;C++)V(A[C],"video");for(var O=t.querySelectorAll(s("audio-attachment")+":not([data-dt-ready])"),m=0;m<O.length;m++)V(O[m],"audio");for(var S=t.querySelectorAll(s("reaction")+":not([data-dt-ready])"),b=0;b<S.length;b++)ht(S[b]);for(var I=t.querySelectorAll(s("pre")+":not([data-dt-ready])"),j=0;j<I.length;j++)mt(I[j]);gt(t),St(t),wt(t)}}function wt(t){for(var r=t.querySelectorAll(s("messages")),e=0;e<r.length;e++)r[e].hasAttribute("light-theme")&&!r[e].hasAttribute("data-theme")&&r[e].setAttribute("data-theme","light")}function qt(t){var r=t.target;if(!(!r||!r.closest)){var e=r.closest("discord-spoiler");if(e){G(e);return}var a=r.closest(".dt-spoiler-overlay");if(a&&a.parentElement){a.parentElement.setAttribute("data-dt-revealed","");return}var i=r.closest("discord-reaction");if(i&&i.hasAttribute("data-dt-ready")){var d=bt(i);c(i,"reacted")?(i.removeAttribute("reacted"),H(i,Math.max(1,d-1))):(i.setAttribute("reacted",""),H(i,d+1));return}var o=r.closest(".dt-copy");if(o&&o.parentElement&&navigator.clipboard){var u=o.parentElement,f=u.querySelector(s("code")+", pre, code");navigator.clipboard.writeText((f||u).textContent).then(function(){o.textContent="Copied",setTimeout(function(){o.textContent="Copy"},1200)})}}}function Dt(t){if(!(t.key!=="Enter"&&t.key!==" ")){var r=t.target;if(!(!r||!r.closest)){var e=r.closest("discord-spoiler");e&&(t.preventDefault(),G(e))}}}var _=null;function Mt(t){_||(_=window.requestAnimationFrame(function(){_=null,k(t||document)}))}function Z(){if(k(document),document.addEventListener("click",qt,!1),document.addEventListener("keydown",Dt,!1),window.setInterval&&Q.push(window.setInterval(function(){w.length&&Y()},6e4)),q().observe!==!1&&window.MutationObserver){var t=new MutationObserver(function(r){for(var e=0;e<r.length;e++)if(r[e].addedNodes.length){Mt(document);return}});t.observe(document.documentElement,{childList:!0,subtree:!0})}}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",Z,!1):Z(),window.DiscordTranscript={version:J,upgrade:function(t){k(t||document)},refresh:Y,formatStamp:F,parseStamp:T}})();
|