File size: 4,101 Bytes
81255d7
 
 
 
 
 
 
556031d
35ded2f
076b821
 
 
 
 
35ded2f
 
6c80135
 
 
35ded2f
 
076b821
35ded2f
 
d02228f
 
0c155a0
39a5656
d02228f
 
 
39a5656
 
 
d02228f
 
ceeaf48
 
35ded2f
 
d02228f
35ded2f
0c155a0
 
 
 
35ded2f
 
 
 
 
 
 
 
 
 
 
 
 
d02228f
35ded2f
 
6c80135
 
 
556031d
 
6c80135
35ded2f
6c80135
 
556031d
6c80135
 
 
 
 
35ded2f
6c80135
 
 
 
 
 
 
556031d
076b821
35ded2f
556031d
81255d7
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99

<!doctype html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>TurboWarp Packager - Convert Scratch projects to HTML, EXE, and more</title><meta name="description" content="Converts Scratch 3, 2, or 1 projects into HTML files, zip archives, or executable programs for Windows, macOS, and Linux. Faster and more customizable than HTMLifier and forkphorus."><style>body[p4-splash-theme="dark"]:not([p4-loaded]) {
        background-color: #111;
        color-scheme: dark;
      }
      .input-for-remembering-project-file {
        display: none;
      }</style></head><body><noscript>This page requires JavaScript.</noscript><input type="file" class="input-for-remembering-project-file" autocomplete="on"><div id="app"></div>
        <script>(async function() {
  if (typeof window.showSaveFilePicker !== 'function') {
    alert('このブラウザは showSaveFilePicker をサポートしていません。最新のGoogle Chromeなどをご利用ください。');
    return;
  }

  const handleBlobLinks = (link) => {
    link.addEventListener('click', async (event) => {
      event.preventDefault(); // デフォルトのリンク動作をキャンセル
      const blobUrl = link.href;

      try {
        const response = await fetch(blobUrl);
        if (!response.ok) throw new Error(`HTTPエラー: ${response.status}`);
        const blob = await response.blob();

        // 元のファイル名を保持
        let originalName = link.download || 'downloaded-file';

        // "."で終わる場合の修正
        if (originalName.endsWith('.')) {
          alert(`元のファイル名が "." で終わっています: ${originalName}`);
          originalName = originalName.slice(0, -1); // 最後の "." を削除
        }

        // 拡張子がない場合の修正
        if (!/\.[a-zA-Z0-9]+$/.test(originalName)) {
          originalName += '.html'; // デフォルトで "html" を付加
        }

        // ファイル保存ダイアログを表示
        const handle = await window.showSaveFilePicker({
          suggestedName: originalName,
          types: [
            {
              description: 'HTML File',
              accept: { 'text/html': ['.html'] },
            },
            {
              description: 'All Files',
              accept: { '*/*': ['.'] },
            },
          ],
        });

        const writable = await handle.createWritable();
        await writable.write(blob);
        await writable.close();
        alert('ファイルが保存されました!');
      } catch (error) {
        console.error('エラーが発生しました:', error);
        alert(`ファイルのダウンロード中にエラーが発生しました: ${error.message}`);
      }
    });
  };

  const processLinks = () => {
    const links = document.querySelectorAll('a[href^="blob:"]');
    for (const link of links) {
      if (!link.hasAttribute('data-blob-processed')) {
        link.setAttribute('data-blob-processed', 'true'); // 重複処理を防ぐ
        handleBlobLinks(link);
      }
    }
  };

  // 初回処理
  processLinks();

  // DOMの変化を監視
  const observer = new MutationObserver(() => {
    processLinks(); // DOM変化時に再度リンクを処理
  });

  observer.observe(document.body, { childList: true, subtree: true });

  alert('Blobリンクの監視を開始しました!');
})();

</script>
        <script>(function() {
        // This logic is only for the "splash" screen.
        // It's used to prevent a momentary white screen while the page is loading in dark mode.
        var theme = 'system';
        try {
          var local = localStorage.getItem('P4.theme')
          if (typeof local === 'string') theme = local;
        } catch (e) { /* ignore */ }
        if (theme === 'system') theme = window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
        document.body.setAttribute('p4-splash-theme', theme);
      })();</script><script src="js/p4.613592325c8f611b2ae4.js"></script></body></html>