diff --git a/raw.js b/raw.js index b4ede54..7e525e2 100644 --- a/raw.js +++ b/raw.js @@ -1,162 +1,156 @@ - (function () { +(function () { try { var articles = document.querySelectorAll('article'); var timestamp = new Date().toLocaleString(); - // HTML Template - var htmlContent = ` - - - - - Chat Export - - - - - -

${window.location.href}

-
Exported on: ${timestamp}
-
-`; + var currentHref = window.location.href; + + var htmlContent = "" + + "\n" + + "\n" + + "\n" + + " \n" + + " Chat Export\n" + + " \n" + + " \n" + + " \n" + + "\n" + + "\n" + + "

" + currentHref + "

\n" + + "
Exported on: " + timestamp + "
\n" + + "
\n"; - // Process articles and add messages - articles.forEach(function (article, index) { + // Nachrichten verarbeiten + for (var i = 0; i < articles.length; i++) { + var article = articles[i]; var messageContent = article.querySelector('.whitespace-pre-wrap, .markdown'); - var imagesHtml = ''; - + var imagesHtml = ""; if (messageContent) { var images = article.querySelectorAll('img[width][height]'); - images.forEach(function (image) { - imagesHtml += image.outerHTML; - }); - - htmlContent += ` -
-
- ${imagesHtml}${messageContent.innerHTML} -
-
- `; + for (var j = 0; j < images.length; j++) { + imagesHtml += images[j].outerHTML; + } + htmlContent += "" + + "
\n" + + "
\n" + + " " + imagesHtml + messageContent.innerHTML + "\n" + + "
\n" + + "
\n"; } - }); + } - // Close HTML content - htmlContent += ` -
- - - - -`; + htmlContent += "" + + "
\n" + + " \n" + + " \n" + + "\n" + + "\n"; - // Copy to clipboard var textarea = document.createElement('textarea'); textarea.value = htmlContent; textarea.setAttribute('readonly', ''); @@ -164,10 +158,14 @@ textarea.style.left = '-9999px'; document.body.appendChild(textarea); textarea.select(); - var success = document.execCommand('copy'); + var success = false; + try { + success = document.execCommand('copy'); + } catch (e) { + // Fehler beim Kopieren + } document.body.removeChild(textarea); - // Notify the user if (success) { alert('Complete HTML file with syntax highlighting and timestamp copied to clipboard.'); } else {