Created
April 11, 2023 15:54
-
-
Save SleepingInsomniac/db218962cef2080c69df85ad2e27693c to your computer and use it in GitHub Desktop.
Safari bookmark script to download a chatGPT chat
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| javascript:(function() { | |
| var chatgptContent = document.querySelector('main > div > div > div').innerHTML; | |
| var pageTitle = document.title.replace(/[^a-zA-Z0-9\s]/g, "").replace(/\s+/g, "_"); | |
| var styles = ''; | |
| for (var i = 0; i < document.styleSheets.length; i++) { | |
| var styleSheet = document.styleSheets[i]; | |
| try { | |
| if (styleSheet.cssRules) { | |
| for (var j = 0; j < styleSheet.cssRules.length; j++) { | |
| styles += styleSheet.cssRules[j].cssText; | |
| } | |
| } | |
| } catch (e) { | |
| console.log('Error: Unable to load CSS rules from ' + styleSheet.href); | |
| } | |
| } | |
| var htmlContent = '<html><head><title>' + pageTitle + '</title><style>' + styles + '</style></head><body>' + chatgptContent + '</body></html>'; | |
| var blob = new Blob([htmlContent], {type: 'text/html;charset=utf-8'}); | |
| var link = document.createElement('a'); | |
| link.href = URL.createObjectURL(blob); | |
| link.download = pageTitle + '.html'; | |
| link.style.display = 'none'; | |
| document.body.appendChild(link); | |
| link.click(); | |
| document.body.removeChild(link); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment