ZIP化!「260815_超かぐや姫おつかれさま本」

    @@ -1,6 +1,6 @@ /* * @title 「260815_超かぐや姫おつかれさま本」ダウンロード - * @description Dropboxから「260815_超かぐや姫おつかれさま本」の画像をZIP形式でダウンロードする + * @description Dropboxから「260815_超かぐや姫おつかれさま本」 https://www.dropbox.com/scl/fi/2dz2rnch41n0ym6svx2v1/260815_.pdf?rlkey=79hr9bq43shkosbwhe93003lu&st=z03mvt95&e=1&dl=0 の画像をZIP形式でダウンロードする * @include https://www.dropbox.com/* * @license MIT License * @require
  • /*
     * @title 「260815_超かぐや姫おつかれさま本」ダウンロード
     * @description Dropboxから「260815_超かぐや姫おつかれさま本」 https://www.dropbox.com/scl/fi/2dz2rnch41n0ym6svx2v1/260815_.pdf?rlkey=79hr9bq43shkosbwhe93003lu&st=z03mvt95&e=1&dl=0 の画像をZIP形式でダウンロードする
     * @include https://www.dropbox.com/*
     * @license MIT License
     * @require 
     * @javascript_url
     */
    
    (async () => {
        const wait = msec => new Promise(resolve => setTimeout(resolve, msec));
        const script = document.createElement('script');
        script.nonce = document.querySelector('script[nonce]').nonce;
        script.src = 'https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js';
        document.documentElement.append(script);
        for (let ci of [...Array(50)].map((_, i) => i)) {
            console.log(ci);
            if (typeof JSZip !== undefined) break;
            await wait(100);
        }
        if (typeof JSZip === undefined) {
            alert('Failed to load JSZIP');
            return;
        }
        const document_title = document.querySelector('title').textContent;
        const max_page = document.querySelector('[data-testid="page-count"]').textContent.match(/\/\s*(\d+)\s*/)[1] - 0;
        const max_page_strlen = `${max_page}`.length;
        const sample_img = document.querySelector('[data-testid="preview-viewport"] [id^="pageContainer"][data-index] img');
        const img_url = new URL(sample_img.src);
        const img_ext = img_url.pathname.match(/\.[^.]+$/)[0];
        const zip = new JSZip();
        for (page=0; page < max_page; page++) {
            const page_str = `${page+1}`.padStart(max_page_strlen, 0);
            img_url.searchParams.set('page', page);
            const response = await fetch(img_url.href);
            if (! response.ok) {
                console.error(`Fetch failure: page ${page_str}`);
                continue;
            }
            zip.file(`${page_str}${img_ext}`, await response.arrayBuffer());
        }
        const blob = await zip.generateAsync({type: 'blob', compression: 'STORE'});
        const download_link = document.createElement('a');
        download_link.href = URL.createObjectURL(blob);
        download_link.download = `${document_title.replace(/\.[^.]+$/,'')}.zip`;
        document.documentElement.append(download_link);
        download_link.click();
        download_link.remove();
    })();
    
  • Permalink
    このページへの個別リンクです。
    RAW
    書かれたコードへの直接のリンクです。
    Packed
    文字列が圧縮された書かれたコードへのリンクです。
    Userscript
    Greasemonkey 等で利用する場合の .user.js へのリンクです。
    Loader
    @require やソースコードが長い場合に多段ロードする Loader コミのコードへのリンクです。
    Metadata
    コード中にコメントで @xxx と書かれたメタデータの JSON です。

History

  1. 2026/08/16 17:34:59 - 4 hours ago
  2. 2026/08/16 17:13:19 - 4 hours ago
  3. 2026/08/16 15:47:03 - 5 hours ago
  4. 2026/08/16 06:07:08 - 15 hours ago
  5. 2026/08/16 05:58:14 - 15 hours ago
  6. 2026/08/16 05:50:21 - 15 hours ago
  7. 2026/08/16 04:52:38 - 16 hours ago
  8. 2026/08/16 03:08:06 - 18 hours ago
  9. 2026/08/16 03:01:09 - 18 hours ago
  10. 2026/08/16 02:40:58 - 19 hours ago
  11. 2026/08/16 02:40:08 - 19 hours ago
  12. 2026/08/16 02:34:23 - 19 hours ago
  13. 2026/08/16 02:33:56 - 19 hours ago
  14. 2026/08/16 02:32:11 - 19 hours ago
  15. 2026/08/16 02:31:37 - 19 hours ago