dteviot / WebToEpub

A simple Chrome (and Firefox) Extension that converts Web Novels (and other web pages) into an EPUB.
Other
698 stars 135 forks source link

Attempts to Download Next Chapter on Fetch Fail #640

Open Synteresis opened 2 years ago

Synteresis commented 2 years ago

Describe the bug When working on Safari, because of the CORS error in fetch, WebToEpub will attempt to download the Epub after the first link despite not having gotten any chapter content. Afterwards, attempting to click on "Pack Epub" again will result in WebToEpub attempting to download the next chapter instead of starting from the beginning, i.e after attempting and failing to download Chapter 1, it will move on to Chapter 2 the next time clicking on "Pack Epub" and attempt to download it instead. After Chapter 2, it will fail on Chapter 3 instead.

To Reproduce Steps to reproduce the behavior: // Setup Safari Development // May also be able to manually cause CORS or throw the fetch. xcrun the current extension Fix the bug where it wouldn't let the window open more than once

// Bug Use WebToEpub on any website, click on Pack Epub. Cancel the empty download. Click on Pack Epub again.

Reproduced in Chrome and Firefox when deliberately rejecting fetch promise. It may be just the visual download arrow graphic, but I haven't quite read up to that part in the source yet.

static wrapFetchImpl(url, wrapOptions) {
    if (wrapOptions.fetchOptions == null) {
        wrapOptions.fetchOptions = HttpClient.makeOptions();
    }
    if (wrapOptions.errorHandler == null) {
        wrapOptions.errorHandler = new FetchErrorHandler();
    }
    window.fetch = () => {
        return Promise.reject();
    }
    return fetch(url, wrapOptions.fetchOptions).catch(function (error) {
        return wrapOptions.errorHandler.onFetchError(url, error);
    }).then(function(response) {
        return HttpClient.checkResponseAndGetData(url, wrapOptions, response);
    });
}

Expected behavior Instead of moving to the next chapter, when fetch fails, it should attempt to pack the epub again from the first chapter instead of the chapter after whatever it failed at.

Screenshots Screenshots at bottom due to size.

Desktop (please complete the following information): // Simulator was setup on this

Smartphone (please complete the following information): // Extension was run on this

Additional context Chapter list removing first chapter before getting chapter content? Haven't read to that part yet.

Screenshots image image image image

Arsur3215Loki commented 2 years ago

I've encounter a similar problem to yours, it involved with an Anti Bot system that the site, Ranobes.net, had applied a plugin that it would detect a perceive bot and sent to a verification page if whether you are a bot or a human. I had configured the "Max web pages to fetch simultaneously" to 1 just so the site wouldn't be detected. Try it, if it would work. It is slow, but this is the only way I've found to bypass the detection.

Edit: Try using a different site if it would also result the same.

dteviot commented 2 years ago

@Arsur3215Loki See https://github.com/dteviot/WebToEpub/issues/663