修复压缩包
Browse files- youtube_sub.js +32 -58
youtube_sub.js
CHANGED
|
@@ -13,7 +13,7 @@
|
|
| 13 |
// @connect sonygod-flash.hf.space
|
| 14 |
// @require https://cdn.jsdelivr.net/npm/marked/marked.min.js
|
| 15 |
// @require https://cdnjs.cloudflare.com/ajax/libs/dompurify/3.0.6/purify.min.js
|
| 16 |
-
// @require https://
|
| 17 |
// @run-at document-end
|
| 18 |
// ==/UserScript==
|
| 19 |
|
|
@@ -676,74 +676,48 @@ GM_addStyle(`
|
|
| 676 |
// Add export button after existing exports
|
| 677 |
exportDiv.appendChild(createExportButton('Export Words by Letter (ZIP)', async () => {
|
| 678 |
try {
|
|
|
|
| 679 |
console.log('Starting ZIP export...');
|
| 680 |
const words = [...this.loadNewWordsCache()].sort();
|
| 681 |
-
|
| 682 |
-
|
| 683 |
-
|
| 684 |
-
|
| 685 |
-
|
| 686 |
-
// Group and add files
|
| 687 |
-
const groups = words.reduce((acc, word) => {
|
| 688 |
const letter = word[0].toLowerCase();
|
| 689 |
if (/[a-z]/.test(letter)) {
|
| 690 |
-
if (!
|
| 691 |
-
|
| 692 |
}
|
| 693 |
-
|
| 694 |
-
}, {});
|
| 695 |
|
| 696 |
-
|
| 697 |
-
|
| 698 |
-
|
|
|
|
|
|
|
| 699 |
});
|
| 700 |
|
| 701 |
-
//
|
| 702 |
-
|
| 703 |
-
|
| 704 |
-
|
| 705 |
-
|
| 706 |
-
});
|
| 707 |
-
|
| 708 |
-
console.log('ZIP generated in base64');
|
| 709 |
-
|
| 710 |
-
// Define download handler
|
| 711 |
-
const downloadHandler = {
|
| 712 |
-
url: "data:application/zip;base64," + base64,
|
| 713 |
-
name: "words.zip",
|
| 714 |
-
saveAs: true,
|
| 715 |
-
onload: () => console.log('Download started'),
|
| 716 |
-
onerror: (err) => {
|
| 717 |
-
console.error('GM_download failed:', err);
|
| 718 |
-
throw err;
|
| 719 |
-
}
|
| 720 |
-
};
|
| 721 |
|
| 722 |
-
|
| 723 |
-
|
| 724 |
-
|
| 725 |
-
|
| 726 |
-
|
| 727 |
-
|
| 728 |
-
|
| 729 |
-
|
| 730 |
-
|
| 731 |
-
|
| 732 |
-
|
| 733 |
-
|
| 734 |
-
const url = URL.createObjectURL(blob);
|
| 735 |
-
const link = document.createElement('a');
|
| 736 |
-
link.href = url;
|
| 737 |
-
link.download = 'words.zip';
|
| 738 |
-
document.body.appendChild(link);
|
| 739 |
-
link.click();
|
| 740 |
-
document.body.removeChild(link);
|
| 741 |
-
URL.revokeObjectURL(url);
|
| 742 |
-
}
|
| 743 |
|
| 744 |
} catch (error) {
|
| 745 |
-
console.error('ZIP
|
| 746 |
-
alert('Failed to
|
| 747 |
}
|
| 748 |
}));
|
| 749 |
|
|
|
|
| 13 |
// @connect sonygod-flash.hf.space
|
| 14 |
// @require https://cdn.jsdelivr.net/npm/marked/marked.min.js
|
| 15 |
// @require https://cdnjs.cloudflare.com/ajax/libs/dompurify/3.0.6/purify.min.js
|
| 16 |
+
// @require https://cdn.jsdelivr.net/npm/fflate/umd/index.js
|
| 17 |
// @run-at document-end
|
| 18 |
// ==/UserScript==
|
| 19 |
|
|
|
|
| 676 |
// Add export button after existing exports
|
| 677 |
exportDiv.appendChild(createExportButton('Export Words by Letter (ZIP)', async () => {
|
| 678 |
try {
|
| 679 |
+
|
| 680 |
console.log('Starting ZIP export...');
|
| 681 |
const words = [...this.loadNewWordsCache()].sort();
|
| 682 |
+
|
| 683 |
+
// Group words by letter
|
| 684 |
+
const files = {};
|
| 685 |
+
words.forEach(word => {
|
|
|
|
|
|
|
|
|
|
| 686 |
const letter = word[0].toLowerCase();
|
| 687 |
if (/[a-z]/.test(letter)) {
|
| 688 |
+
if (!files[letter]) files[letter] = [];
|
| 689 |
+
files[letter].push(word);
|
| 690 |
}
|
| 691 |
+
});
|
|
|
|
| 692 |
|
| 693 |
+
// Prepare files for ZIP
|
| 694 |
+
const zipObj = {};
|
| 695 |
+
Object.entries(files).forEach(([letter, words]) => {
|
| 696 |
+
const content = words.join('\n');
|
| 697 |
+
zipObj[`${letter}.txt`] = new TextEncoder().encode(content);
|
| 698 |
});
|
| 699 |
|
| 700 |
+
// Create ZIP using fflate
|
| 701 |
+
const zipData = fflate.zipSync(zipObj, {
|
| 702 |
+
level: 6,
|
| 703 |
+
mem: 8
|
| 704 |
+
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 705 |
|
| 706 |
+
// Convert to blob and download
|
| 707 |
+
const blob = new Blob([zipData], { type: 'application/zip' });
|
| 708 |
+
const url = URL.createObjectURL(blob);
|
| 709 |
+
const link = document.createElement('a');
|
| 710 |
+
link.href = url;
|
| 711 |
+
link.download = 'words.zip';
|
| 712 |
+
document.body.appendChild(link);
|
| 713 |
+
link.click();
|
| 714 |
+
document.body.removeChild(link);
|
| 715 |
+
URL.revokeObjectURL(url);
|
| 716 |
+
console.log('ZIP download completed');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 717 |
|
| 718 |
} catch (error) {
|
| 719 |
+
console.error('ZIP generation failed:', error);
|
| 720 |
+
alert('Failed to create ZIP file: ' + error.message);
|
| 721 |
}
|
| 722 |
}));
|
| 723 |
|