diff --git a/assets/css/index.css b/assets/css/index.css index 2cb75b6..b46aa4e 100644 --- a/assets/css/index.css +++ b/assets/css/index.css @@ -908,8 +908,7 @@ body:not(.gui) .chooser>.back { } .bottom { - height: 40%; - margin: 40px auto auto auto!important; + /* margin: 40px auto auto auto!important; */ max-width: 90%; } @@ -1694,4 +1693,7 @@ body { top: 70px; left: 10px; } + .top>.gui { + margin-top: 5px; + } } \ No newline at end of file diff --git a/assets/js/index.js b/assets/js/index.js index 54acd30..f310d09 100644 --- a/assets/js/index.js +++ b/assets/js/index.js @@ -130,6 +130,7 @@ window.onload = () => { embedImage = document.querySelector('.embedImage'), embedThumbnail = document.querySelector('.embedThumbnail'), embedFields = embed.querySelector('.embedFields'), + encodeHTML = str => str.replace(/[\u00A0-\u9999<>\&]/g, i => '&#' + i.charCodeAt(0) + ';'), tstamp = stringISO => { let date = stringISO ? new Date(stringISO) : new Date(), dateArray = date.toLocaleString('en-US', { hour: 'numeric', hour12: true, minute: 'numeric' }), @@ -148,17 +149,17 @@ window.onload = () => { gui.innerHTML = `

Message content

- +

Author

- - + +
- +
@@ -190,11 +191,11 @@ window.onload = () => {

Title

- +

Description

- +

Fields

@@ -202,9 +203,9 @@ window.onload = () => {
- +
- + @@ -239,9 +240,9 @@ window.onload = () => {
- +
- + @@ -276,11 +277,11 @@ window.onload = () => {
- - + +
- +
@@ -350,10 +351,10 @@ window.onload = () => {
- +
- +
@@ -515,29 +516,29 @@ window.onload = () => { fields = gui.querySelector('.fields ~ .edit'); update = data => { try { - embedContent.innerHTML = data.content ? markup(data.content, { replaceEmojis: true }) : ''; + embedContent.innerHTML = data.content ? markup(encodeHTML(data.content), { replaceEmojis: true }) : ''; if (data.embed && Object.keys(data.embed).length) { let e = data.embed; if (!allGood(e)) return; - if (e.title) display(embedTitle, markup(`${e.url ? '' + e.title + '' : e.title}`, { replaceEmojis: true, inlineBlock: true })); + if (e.title) display(embedTitle, markup(`${e.url ? '' + encodeHTML(e.title) + '' : encodeHTML(e.title)}`, { replaceEmojis: true, inlineBlock: true })); else hide(embedTitle); - if (e.description) display(embedDescription, markup(e.description, { inEmbed: true, replaceEmojis: true })); + if (e.description) display(embedDescription, markup(encodeHTML(e.description), { inEmbed: true, replaceEmojis: true })); else hide(embedDescription); - if (e.color) embed.closest('.embed').style.borderColor = (typeof e.color === 'number' ? '#' + e.color.toString(16).padStart(6, "0") : e.color); + if (e.color) embed.closest('.embed').style.borderColor = encodeHTML(typeof e.color === 'number' ? '#' + e.color.toString(16).padStart(6, "0") : e.color); else embed.closest('.embed').style.removeProperty('border-color'); if (e.author && e.author.name) display(embedAuthor, ` - ${e.author.icon_url ? '' : ''} - ${e.author.url ? '' + e.author.name + '' : '' + e.author.name + ''}`, 'flex'); + ${e.author.icon_url ? '' : ''} + ${e.author.url ? '' + encodeHTML(e.author.name) + '' : '' + encodeHTML(e.author.name) + ''}`, 'flex'); else hide(embedAuthor); - if (e.thumbnail && e.thumbnail.url) embedThumbnail.src = e.thumbnail.url, embedThumbnail.style.display = 'block'; + if (e.thumbnail && e.thumbnail.url) embedThumbnail.src = encodeHTML(e.thumbnail.url), embedThumbnail.style.display = 'block'; else hide(embedThumbnail); - if (e.image && e.image.url) embedImage.src = e.image.url, embedImage.style.display = 'block'; + if (e.image && e.image.url) embedImage.src = encodeHTML(e.image.url), embedImage.style.display = 'block'; else hide(embedImage); if (e.footer && e.footer.text) display(embedFooter, ` - ${e.footer.icon_url ? '' : ''} - ${e.footer.text} - ${e.timestamp ? '' + tstamp(e.timestamp) : ''}
`, 'flex'); - else if (e.timestamp) display(embedFooter, `${tstamp(e.timestamp)}
`, 'flex'); + ${e.footer.icon_url ? '' : ''} + ${encodeHTML(e.footer.text)} + ${e.timestamp ? '' + encodeHTML(tstamp(e.timestamp)) : ''}
`, 'flex'); + else if (e.timestamp) display(embedFooter, `${encodeHTML(tstamp(e.timestamp))}
`, 'flex'); else hide(embedFooter); if (e.fields) { embedFields.innerHTML = ''; @@ -547,15 +548,15 @@ window.onload = () => { let el = embedFields.insertBefore(document.createElement('div'), null); el.outerHTML = `
-
${markup(f.name, { inEmbed: true, replaceEmojis: true, inlineBlock: true })}
-
${markup(f.value, { inEmbed: true, replaceEmojis: true })}
+
${markup(encodeHTML(f.name), { inEmbed: true, replaceEmojis: true, inlineBlock: true })}
+
${markup(encodeHTML(f.value), { inEmbed: true, replaceEmojis: true })}
`; } else { el = embedFields.insertBefore(document.createElement('div'), null); el.outerHTML = `
-
${markup(f.name, { inEmbed: true, replaceEmojis: true, inlineBlock: true })}
-
${markup(f.value, { inEmbed: true, replaceEmojis: true })}
+
${markup(encodeHTML(f.name), { inEmbed: true, replaceEmojis: true, inlineBlock: true })}
+
${markup(encodeHTML(f.value), { inEmbed: true, replaceEmojis: true })}
`; colNum = (colNum === 9 ? 1 : colNum + 4); num++;