13 ms·
Singlefile: A web extension to save a complete web page into a single HTML file
- n8henrie 2y agoIf anyone wants to help me update the nix package for the CLI, I'd appreciate it. The whole Deno thing is foreign territory for me. https://github.com/NixOS/nixpkgs/blob/81629effd3f7e0cea0c1cf983efb87fee31bb103/pkgs/by-name/si/single-file-cli/package.nix#L39 https://github.com/NixOS/nixpkgs/blob/81629effd3f7e0cea0c1cf...
- mdaniel 2y agoYou linked to an invocation of grep without any further context. What, specifically, do you need help with?
- n8henrie 2y ago> You linked to an invocation of grep without any further context. I linked to an invocation of grep in the package in question. Sorry, on mobile so I just copied the first link to the package from my search results. > What, specifically, do you need help with? As I mentioned, I don't know how deno works. To elaborate, now that single-file-cli is using deno, I don't know how to package something that uses deno for nix.
- maxloh 2y agoChromium-based browsers (Chrome, Edge, Brave, etc.) already have great MHTML support. Just right click on a page > "Save as...", and select "Webpage, Single File" in the dialog.
- thekevan 2y agoI was just going to ask why this was better than just saving an MHTML file in the browser.
- gildas 2y agoBecause the MHTML format produced by Chromium can almost be considered as proprietary.
- maxloh 2y agoThat's not correct. MHTML has been defined as internet standard since 1999. MHTML has been an internet standard since 1999, with support dating back to IE 5.0. https://datatracker.ietf.org/doc/html/rfc2557 https://datatracker.ietf.org/doc/html/rfc2557
- gildas 2y agoI'm actually referring to the "set of modifications" described here [1] and the fact that only Chromium can open (these) MHTML files today. [1] https://docs.google.com/document/d/1FvmYUC0S0BkdkR7wZsg0hLdKc_qjGnGahBwwa0CdnHE https://docs.google.com/document/d/1FvmYUC0S0BkdkR7wZsg0hLdK...
- maxloh 2y agoGood to know that! Are you meaning that these modifications cause the generated MHTML files to become non-standards-compliant? I wouldn't consider them proprietary though. At least the primary software used to open these files, Chromium, is open-source software.
- gildas 2y agoI agree that it's debatable, which is why I used the word “almost” ;). The fact remains that this info isn't in RFCs and is hard to find on the web.
- maxloh 2y agoIt seems that Firefox doesn't support saving a page as MHTML yet. Maybe that's the reason. https://connect.mozilla.org/t5/ideas/add-support-of-mhtml-format/idi-p/7244 https://connect.mozilla.org/t5/ideas/add-support-of-mhtml-fo...
- freehorse 2y agoBecause having just an html file can just be simpler and html files are more ubiquitously rendered. Personally having a single html file with base64 encoded images embedded into it serves 99.9% of what I usually want to do when wanting to have a webpage saved offline. Such a file can be eg be put in my dropbox and rendered in dropbox web interface which makes it easy to share with others. I have actually made a script that looks for image tags in an html file on my computer, looks in the local directory location for them and base64 embeds them in the html file itself, so this seems to simplify the process.
- hahn-kev 2y agoIf that's all you want then couldn't you just print to PDF?
- eviks 2y agoIt's not responsive anymore
- freehorse 2y agoBecause I do not want a page structure in the document. Images are arranged better in an html file because a pdf would have to arrange things into pages and thus create undesirable gaps or put images in weird ways. Plus html is just a text file I can further edit if I want.
- mdaniel 2y agoseems there was some robust discussion on the 2022 submission https://news.ycombinator.com/item?id=30527999 https://news.ycombinator.com/item?id=30527999 but I didn't dig into it to discover "but, why?" as compared to the "save" built into the browsers having said that, this here is an instant "nope" for me https://github.com/gildas-lormeau/SingleFile/blob/master/faq.md#why-dont-interactive-elements-like-folding-titles-dynamic-maps-or-carousels-work-properly-in-saved-pages https://github.com/gildas-lormeau/SingleFile/blob/master/faq... > By default, SingleFile removes scripts because they can alter the rendering and there is no guarantee they will work offline. so, not complete; got it
- freehorse 2y agoThe very next sentence says > However, you can save them by unchecking the option "Network > blocked resources > scripts" [..]
- mdaniel 2y agoYeah, understood, there seems to be a bunch of "yes, well, monkey with this thing" options, but if the default behavior is not to preserve all the resources because of some pearl-clutching paranoia or whatever, then it's not a complete web page now is it?
- varelaseb 2y agoThis is the worst gotcha I've ever seen
- wakawaka28 2y agoIt depends what you want... Lots of JS will not work offline and I don't think a plugin can know what will work or not. If the page is dynamically populated from an API, saving the page to rely on JS later could be basically wrong.
- lynndotpy 2y agoIt's not paranoia, it's a feature that I consider to be useful and desirable. When I want to download the JavaScript, I use the built-in "save" feature. When I don't, I use SingleFile.
- dannyobrien 2y agoIf today's Hacker News trend is "ways to archive web pages for permanent storage", let me also point folks to https://webrecorder.net/archivewebpage/ https://webrecorder.net/archivewebpage/ and the WebRecorder suite of tools.
- glenstein 2y agoThanks for this recommendation, this is exactly a kind of tool that I think I had hoped might exist out there somewhere. I don't suppose there's a Firefox version?
- dang 2y agoWhat other thread(s) from today are you thinking of? (maybe https://news.ycombinator.com/item?id=42441609 https://news.ycombinator.com/item?id=42441609?) We try to avoid repetition on the frontpage—people tend to post related/follow-up links as submissions (bad) instead of in the comments (good, as you did here!) https://hn.algolia.com/?dateRange=all&page=0&prefix=true&query=follow-up%20downweight&sort=byDate&type=comment https://hn.algolia.com/?dateRange=all&page=0&prefix=true&que...
- dannyobrien 2y agoYep, that was the one -- I think it was more dominated by "how to save webpages" discussions when I was looking at it. I had no idea that posting in the comments was preferred (though it does make sense!)
- crgk 2y agoFWIW, the discussion you linked came to my mind when I saw this one.
- dang 2y agoRelated. Others? How SingleFile Transformed My Obsidian Workflow - https://news.ycombinator.com/item?id=39147615 https://news.ycombinator.com/item?id=39147615 - Jan 2024 (1 comment) New Feature: Self-Extracting Zip Files Added to SingleFile - https://news.ycombinator.com/item?id=37791838 https://news.ycombinator.com/item?id=37791838 - Oct 2023 (1 comment) Show HN: SingleFile is finally available on Safari (macOS/iOS) - https://news.ycombinator.com/item?id=33643192 https://news.ycombinator.com/item?id=33643192 - Nov 2022 (50 comments) SingleFile version compatible with Manifest V3 - https://news.ycombinator.com/item?id=33063619 https://news.ycombinator.com/item?id=33063619 - Oct 2022 (274 comments) SingleFile: Save a complete web page into a single HTML file - https://news.ycombinator.com/item?id=30527999 https://news.ycombinator.com/item?id=30527999 - March 2022 (240 comments) Show HN: SingleFile Lite, new version of SingleFile compatible with Manifest V3 - https://news.ycombinator.com/item?id=29331038 https://news.ycombinator.com/item?id=29331038 - Nov 2021 (2 comments) Show HN: Save web pages as self-extracting HTML/ZIP files from the CLI - https://news.ycombinator.com/item?id=25218947 https://news.ycombinator.com/item?id=25218947 - Nov 2020 (3 comments) Browser extension and CLI tool to save a complete webpage as single HTML file - https://news.ycombinator.com/item?id=22449602 https://news.ycombinator.com/item?id=22449602 - Feb 2020 (1 comment) Store the proof of a webpage saved with SingleFile in Bitcoin - https://news.ycombinator.com/item?id=21970779 https://news.ycombinator.com/item?id=21970779 - Jan 2020 (77 comments) SingleFileZ, a web extension for saving pages as HTML/ZIP hybrid files - https://news.ycombinator.com/item?id=21426056 https://news.ycombinator.com/item?id=21426056 - Nov 2019 (36 comments) Show HN: SingleFileZ – Save a web page in a HTML file which is also a zip file - https://news.ycombinator.com/item?id=19933196 https://news.ycombinator.com/item?id=19933196 - May 2019 (18 comments) SingleFile can now save a web page from the command line - https://news.ycombinator.com/item?id=18974357 https://news.ycombinator.com/item?id=18974357 - Jan 2019 (2 comments) SingleFile 1.0 is out - https://news.ycombinator.com/item?id=17457943 https://news.ycombinator.com/item?id=17457943 - July 2018 (1 comment)
- Dwedit 2y agoI was working on a trick to save files in a more compact way by taking advantage of UTF-16 encoded HTML files. I have an example HTML files on my website here: https://www.dwedit.org/files/test.html https://www.dwedit.org/files/test.html (Tip: type "codeText" into the JS console to see the second-stage loader. First stage-loader is in clear text in the source) It's storing a 64479 byte JPEG into 64680 bytes of UTF-16 text, for around 0.2985% expansion. The decoder isn't size-optimized right now (there's even comments in the code), so it takes about 10KB more. This is doing two things: First stage is a basic kind of UTF-16 packing, where you use a simple Javascript string literal, and anything that needs escaping gets escaped. This keeps most 8-bit data the same size, but byte pairs that turn into a forbidden string character get escaped. Then you split your result string into bytes. Forbidden characters (requiring escaping) in a Javascript string: 0x00, 0x0A, 0x0D, 0x22, 0x5C, 0x2028, 0x2029, 0xD800-0xDFFF --- Second stage involves using very large integers to pack 335 bits into every 336 actual bits. This avoids all escaping completely in the JS string, as you can avoid the forbidden characters. During decoding, my code is using a handmade 48-bit BigInt (actually stores 7 48-bit words for 336 total bits), allowing support on web browsers that predate native bigints, and it runs faster too. Let me know if I should make an article about this. (I also made a WASM version of the decoder to see if it would run any faster, but it didn't.)
- gildas 2y agoI took another approach in SingleFile by offering a way to save pages as self-extracting pages (i.e. ZIP/HTML polyglot files), see [1] for more info. [1] https://github.com/gildas-lormeau/Polyglot-HTML-ZIP-PNG https://github.com/gildas-lormeau/Polyglot-HTML-ZIP-PNG
- Dwedit 2y agoReally cool stuff there, how did you read the bytes back? Normally you get a CORS error if you try to use a network request to read back yourself.
- gildas 2y agoThe saved page is encoded in windows-1252. It includes "consolidation data" to read the ZIP data as text from the DOM and recover the replacements of \r and \r\n occurrences (this is the only data loss and it represents approx. 1% of ZIP data), see the links below for more info. https://gildas-lormeau.github.io/Polyglot-HTML-ZIP-PNG/en-EN/dist/presentation-polyglot-png-zip-html_en-EN.html#/51 https://gildas-lormeau.github.io/Polyglot-HTML-ZIP-PNG/en-EN... https://gildas-lormeau.github.io/Polyglot-HTML-ZIP-PNG/en-EN/dist/presentation-polyglot-png-zip-html_en-EN.html#/55/0/0 https://gildas-lormeau.github.io/Polyglot-HTML-ZIP-PNG/en-EN... https://gildas-lormeau.github.io/Polyglot-HTML-ZIP-PNG/en-EN/dist/presentation-polyglot-png-zip-html_en-EN.html#/58/0/4 https://gildas-lormeau.github.io/Polyglot-HTML-ZIP-PNG/en-EN...
- create-username 2y agoStill no way to make a backup of xml books or BlinkLearning websites
- pentagrama 2y agoTried it, and it worked perfectly. Neat! But should I uninstall it? I noticed that this extension (at least the Firefox version) requires "Access your data for all websites" and there's no option to grant access only when needed, clinking on the extension button. I’m not comfortable with extensions having access to all my browsing data unless it’s absolutely necessary (e.g., uBlock Origin).
- gildas 2y agoSingleFile respects your privacy, you can find the privacy policy here [1]. [1] https://github.com/gildas-lormeau/SingleFile/blob/master/privacy.md https://github.com/gildas-lormeau/SingleFile/blob/master/pri...
- jftuga 2y agoI use this extension to locally save my Claude chats. It does a great job preserving code blocks.
- xrd 2y agoJust saying, my static blog tool does this: https://www.npmjs.com/package/svekyll-cli https://www.npmjs.com/package/svekyll-cli https://extrastatic.dev/svekyll/svekyll-cli https://extrastatic.dev/svekyll/svekyll-cli There is something really exciting about creating a communication medium that is in a single file. It feels like you can then easily publish to any web server, but also to things like IPFS.
- betaby 2y agoFor command line I can recommend `monolith` https://github.com/Y2Z/monolith https://github.com/Y2Z/monolith
- nunez 2y agoThis extension is awesome for writing tests while building Web scraping apps.