SingleFile icon indicating copy to clipboard operation
SingleFile copied to clipboard

saving images (and more?) which are directly linked to in the page

Open JackJohnJoe opened this issue 6 years ago • 5 comments

Would it be possible for SF to save pictures that are directly linked to (so whose url ends strictly in .jpg, .png, .gif...) within the saved page? And thus may be expanded again when viewing the saved page. And doing so for videos or audio files would even better, but that may be too complex; and of course some platforms will not allow that like youtube. I am mainly thinking of imageboards, being a heavy user personally (yes, those horrible websites like 4chan).

JackJohnJoe avatar Jul 01 '20 16:07 JackJohnJoe

Implementing this feature might be possible but it would be quite complicated to do so. The problem is that the thumbnail does not point, most of the time, to the image itself but a page displaying the image. It means SingleFile would have to guess where the image is and if it's relevant or not to embed it. Indeed, I don't see how SingleFile could know when this should apply or not. For example, on a news website, clicking on a thumbnail allows the user to display the corresponding article, which often contains a large image. In that case, how SingleFile could know it should not add a link to preview the image of the article on the thumbnail?

gildas-lormeau avatar Jul 02 '20 21:07 gildas-lormeau

I see. However, it is the case on imageboards... (as in, the links are direct) And several platforms have their own, known ways of doing it, like Blogspot (I think). It could be a first, simple implementation, but then I know people would complain that it doesn't work on this and that website. I suck at programming and have decided to generally avoid it, but maybe it wouldn't be that hard to implement for a single website. I could always try.

JackJohnJoe avatar Jul 03 '20 08:07 JackJohnJoe

This kind of issue might be easily solved with userscript integration though, see https://github.com/gildas-lormeau/SingleFile/wiki/How-to-execute-a-user-script-before-a-page-is-saved.

For example, the following userscript should "unfold" all the images on 4chan just before saving the page:

// ==UserScript==
// @name         Unfold images
// @namespace    https://github.com/gildas-lormeau/SingleFile
// @version      1.0
// @description  [SingleFile] Unfold all the images
// @author       Gildas Lormeau
// @match        *://boards.4channel.org/*
// @grant        none
// ==/UserScript==

dispatchEvent(new CustomEvent("single-file-user-script-init"));

addEventListener("single-file-on-before-capture-request", () =>
  document.querySelectorAll(".fileThumb > img").forEach(image => image.click())
);

Note: I did not tested entirely the script. I just tested document.querySelectorAll(".fileThumb > img").forEach(image => image.click()).

gildas-lormeau avatar Jul 04 '20 23:07 gildas-lormeau

If you mean expand, that option already exists, I don't remember if it's on 4chan directly or from the widely used 4chanX extension, but it's there. But yes in this case I can just do that, and have a bunch of huge images that impede the reading. But, yeah. And also it would be nice to have the option to either fit the images on the screen, or expand to full resolution. This also 4chanX (or 4chan itself) can do, but I don't think it saves it that way if you just save up the page normally.

Anyway yeah, there are alternatives and stuff I can do already (like Download Star), it was just a suggestion. I dunno.

JackJohnJoe avatar Jul 04 '20 23:07 JackJohnJoe

I think this feature cannot be implemented in SingleFile. However, I think it could be feasible in SingleFileZ. That's why I'm closing the issue but I create another one in the repository SingleFileZ.

gildas-lormeau avatar Jul 20 '20 22:07 gildas-lormeau