Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there image preload? #15

Open
Yoposoc opened this issue Dec 10, 2018 · 4 comments
Open

Is there image preload? #15

Yoposoc opened this issue Dec 10, 2018 · 4 comments

Comments

@Yoposoc
Copy link

Yoposoc commented Dec 10, 2018

Can a preload of the images be implemented somehow? They take quite a while to load.

@beppe9000
Copy link

beppe9000 commented Jun 6, 2019

It's there, just not working properly it seems.

preload() {
if (site.sankakucomplex) return;
const curr = $.current();
Main.req($.find(curr, true));
Main.req($.find(curr, false));
},

async req(node) {
if (!node) return;
const { dataset } = node;
if (dataset.alreadyLoading || dataset.full !== "loading") return;
const { 0: id, 1: api } = Main.getApiInfo(node);
dataset.alreadyLoading = "true";
try {
if (site.sankakucomplex) return await Prog.fn(api + id, id, node);
const request = await fetch(api + id);
const text = await Main.processHttp(request);
Main.processText(text, node, id);
}
catch (e) {
Main.warn();
$("img", node).style.outline = "6px solid red";
console.error(`Main.req failure:\n\n${location.origin + api + id} |`, e);
node.removeAttribute("data-already-loading");
}
},

If there was a way to bypass the CORS policy something like this to explicitly put urls in cache would probably work for firefox:

caches.open('cache1').then(function(cache) {return cache.add("full-size image url");})

Yet I'm not sure where the lag I see comes from. Is it downloading again, or is just lag from loading the blob in the data tag of the image?

If the lag is from actually loading the blob, maybe the gallery can be changed so that all the images are loaded at first in their own img tag and navigation is done by setting css display:none to all the images except the current one.

@Yoposoc
Copy link
Author

Yoposoc commented Jul 2, 2019

Sorry, just saw this.

So.... I'm unclear what I should try? How can I help you get preloading working?

@beppe9000
Copy link

beppe9000 commented Jul 2, 2019

Basically it's bugged due to browser updates. If you can, you could implement the alterations to the loading mechanism to show the images from the src tag and update that with the full res url before showing the next pic in the gallery instead of default preloading logic. I have not much experience with userscript api....

@beppe9000
Copy link

beppe9000 commented Jul 3, 2019

Technically the img solution works. I tried to implement a fix (with r34xxx in mind) but I have no idea how to get the proper full-size file extension without downloading the pages. For example thumbnail is jpg but full-size can be gif, png, jpg ,jpeg, ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants