Description
Apparently, there are some zip files that the library is unable to unzip? I tested them with Winrar and it worked...
On the website https://subdl.com/subtitle/sd20172/white-chicks
Both files below can't be unzipped by the library for some reason
English (Dvdrip)
White.Chicks.DVDRip.XViD-DvP (by: Sinistral)
White Chicks [Eng No Subtitles] [DVDrip] (by: uttamyadav)
`
// ==UserScript==
// @name Zip Extractor - SubDL
// @namespace https://greasyfork.org/en/users/
// @Version 1
// @description Automatically extract the subtitle file before downloading
// @author me
// @match https://subdl.com/subtitle/*
// @require https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js
// @grant none
// ==/UserScript==
(function() {
'use strict';
let pendingDownloadUrl = null; //Variable to store the URL of the pending download URL
document.addEventListener('mousedown', function(event) { //Listen for clicks on the page
pendingDownloadUrl = event.target.href; //Capture the download URL
}); //Finishes the mousedown event listener
document.addEventListener('click', function(event) { // Intercept clicks on the page
if (pendingDownloadUrl) { //If the element clicked was a link
event.preventDefault(); //Prevent the default .zip file download
fetch(pendingDownloadUrl) //Fetch the .zip file
.then(response => { //Check if the response headers indicate a zip file
const contentType = response.headers.get('content-type');
return response.blob();
}).then(blob => { //Extract the contents of the zip file
JSZip.loadAsync(blob).then(zip => { //Extract each file
zip.forEach((relativePath, zipEntry) => {
zipEntry.async('blob').then(content => {
var a = document.createElement('a'); //Create a temporary link to download the extracted file
a.href = URL.createObjectURL(content);
a.download = zipEntry.name; //Use the original file name
document.body.appendChild(a);
a.click(); //Simulate a click to trigger the download
document.body.removeChild(a);
});
});
}).catch(error => {
document.title = 'Error extracting zip file: ' + error; //Update the document title with error message
});
})
pendingDownloadUrl = null; //Reset the pending download URL
}
});
})();
`