user-scripts icon indicating copy to clipboard operation
user-scripts copied to clipboard

request loadAsBlob add time limit (sometimes imagetwist.com wait return response blob without time limit)

Open DandyClubs opened this issue 1 year ago • 0 comments

i test get loadAsBlob imagetwist.com image

sometimes imagetwist.com return some links blob some links wait response without time limit

I try

try {
                const extractor = urlExtractor.getExtractorByHost(imageHost)
                //console.log(extractor,imageURL, extractor.viewMode)

                if (extractor.viewMode === 'origin-download') {
                    imageURL = await image.CheckOnline(imageURL)
                    //imageURL = await image.loadAsBlob(imageURL)
                }
            } catch {
                console.log(imageURL)
                image.markAsBroken(link)
                link.setAttribute('target', '_blank')
            }
CheckOnline(url) {
            return new Promise((resolve, reject) => {
                let timer = setTimeout(() => resolve(url), 5000);
                GM_xmlhttpRequest({
                    method: "GET",
                    url: url,
                    headers: { referer: url, origin: url },
                    responseType: 'blob',
                    onload: function(resp) {
                        resolve(window.URL.createObjectURL(resp.response))
                    },
                    onerror: function(error) {
                        reject(error);
                    }
                })
            })
        },

after 2hour

i test

imagetwist.com return all links blob

request loadAsBlob add time limit

DandyClubs avatar Sep 07 '23 05:09 DandyClubs