(actionsArea, TryAgainButton)
| 99 | } |
| 100 | |
| 101 | function addActionsButtons(actionsArea, TryAgainButton) { |
| 102 | // Export markdown |
| 103 | const exportMd = TryAgainButton.cloneNode(true); |
| 104 | exportMd.id = "download-markdown-button"; |
| 105 | exportMd.setAttribute("share-ext", "true"); |
| 106 | exportMd.title = "Export Markdown"; |
| 107 | |
| 108 | exportMd.innerHTML = setIcon('md'); |
| 109 | exportMd.onclick = () => { |
| 110 | exportMarkdown(); |
| 111 | }; |
| 112 | actionsArea.appendChild(exportMd); |
| 113 | |
| 114 | // Generate PNG |
| 115 | const downloadPngButton = TryAgainButton.cloneNode(true); |
| 116 | downloadPngButton.id = "download-png-button"; |
| 117 | downloadPngButton.setAttribute("share-ext", "true"); |
| 118 | downloadPngButton.title = "Generate PNG"; |
| 119 | downloadPngButton.innerHTML = setIcon('png'); |
| 120 | downloadPngButton.onclick = () => { |
| 121 | downloadThread(); |
| 122 | }; |
| 123 | actionsArea.appendChild(downloadPngButton); |
| 124 | |
| 125 | // Generate PDF |
| 126 | const downloadPdfButton = TryAgainButton.cloneNode(true); |
| 127 | downloadPdfButton.id = "download-pdf-button"; |
| 128 | downloadPdfButton.setAttribute("share-ext", "true"); |
| 129 | downloadPdfButton.title = "Download PDF"; |
| 130 | downloadPdfButton.innerHTML = setIcon('pdf'); |
| 131 | downloadPdfButton.onclick = () => { |
| 132 | downloadThread({ as: Format.PDF }); |
| 133 | }; |
| 134 | actionsArea.appendChild(downloadPdfButton); |
| 135 | |
| 136 | // Refresh |
| 137 | const refreshButton = TryAgainButton.cloneNode(true); |
| 138 | refreshButton.id = "refresh-page-button"; |
| 139 | refreshButton.title = "Refresh the Page"; |
| 140 | refreshButton.innerHTML = setIcon('refresh'); |
| 141 | refreshButton.onclick = () => { |
| 142 | window.location.reload(); |
| 143 | }; |
| 144 | actionsArea.appendChild(refreshButton); |
| 145 | } |
| 146 | |
| 147 | async function exportMarkdown() { |
| 148 | const content = Array.from(document.querySelectorAll('main .items-center>div')).map(i => { |
no test coverage detected