|
3 | 3 | // @description Add AI chat & product/category summaries to Amazon shopping, powered by the latest LLMs like GPT-4o! |
4 | 4 | // @author KudoAI |
5 | 5 | // @namespace https://kudoai.com |
6 | | -// @version 2025.12.16 |
| 6 | +// @version 2026.1.3 |
7 | 7 | // @license MIT |
8 | 8 | // @icon https://amazongpt.kudoai.com/assets/images/icons/app/black-gold-teal/icon48.png?v=8e8ed1c |
9 | 9 | // @icon64 https://amazongpt.kudoai.com/assets/images/icons/app/black-gold-teal/icon64.png?v=8e8ed1c |
|
911 | 911 |
|
912 | 912 | // Download code |
913 | 913 | const code = codeBlock.textContent.replace(/^>> /, '').trim() + '\n' |
914 | | - const dlLink = dom.create.anchor(URL.createObjectURL(new Blob([code], { type: 'text/plain' }))) |
915 | | - const now = new Date(), formattedDate = [ // YYYY-MM-DD |
916 | | - now.getFullYear(), |
917 | | - String(now.getMonth() +1).padStart(2, '0'), |
918 | | - String(now.getDate()).padStart(2, '0') |
919 | | - ].join('-') |
920 | | - dlLink.download /* filename */ = `${app.slug}_${blockLang.name.toLowerCase() || 'code'}_${ |
921 | | - formattedDate}_${Date.now().toString(36)}${ |
922 | | - blockLang.fileExtension ? '.' + blockLang.fileExtension : '' }` |
923 | | - document.body.append(dlLink) ; dlLink.click() ; dlLink.remove() // download code |
924 | | - URL.revokeObjectURL(dlLink.href) // prevent memory leaks |
| 914 | + const date = new Date().toISOString().split('T')[0] // YYYY-MM-DD |
| 915 | + const download = `${app.slug}_${blockLang.name.toLowerCase() || 'code'}_${ |
| 916 | + date}_${Date.now().toString(36)}${blockLang.fileExtension ? '.' + blockLang.fileExtension : ''}` |
| 917 | + const href = URL.createObjectURL(new Blob([code], { type: 'text/plain' })) |
| 918 | + const a = dom.create.anchor(href, '', { download, style: 'display: none' }) |
| 919 | + document.body.append(a) ; a.click() ; a.remove() ; URL.revokeObjectURL(href) |
925 | 920 | } |
926 | 921 | downloadBtn.onmouseenter = downloadBtn.onmouseleave = tooltip.toggle |
927 | 922 |
|
|
1875 | 1870 | xhr({ |
1876 | 1871 | method: 'GET', url: shareURL, |
1877 | 1872 | onload: ({ responseText }) => { |
1878 | | - const dlLink = dom.create.anchor( |
1879 | | - URL.createObjectURL(new Blob([responseText], { type: 'text/html' }))) |
1880 | | - dlLink.download /* filename */ = responseText.match(/<title>([^<]+)<\/title>/i)[1] |
| 1873 | + const download = responseText.match(/<title>([^<]+)<\/title>/i)[1] |
1881 | 1874 | .replace(/\s*[—|/]+\s*/g, ' ') // convert symbols to space for hyphen-casing |
1882 | 1875 | .replace(/\.{2,}/g, '') // strip ellipsis |
1883 | 1876 | .toLowerCase().trim().replace(/\s+/g, '-') // hyphen-case |
1884 | 1877 | + '.html' |
1885 | | - document.body.append(dlLink) ; dlLink.click() ; dlLink.remove() // download HTML |
1886 | | - URL.revokeObjectURL(dlLink.href) // prevent memory leaks |
| 1878 | + const href = URL.createObjectURL(new Blob([responseText], { type: 'text/html' })) |
| 1879 | + const a = dom.create.anchor(href, '', { download, style: 'display: none' }) |
| 1880 | + document.body.append(a) ; a.click() ; a.remove() ; URL.revokeObjectURL(href) |
1887 | 1881 | }, |
1888 | 1882 | onerror: err => log.error('Failed to download chat:', err) |
1889 | 1883 | }) |
|
0 commit comments