soiz commited on
Commit
48e2549
·
verified ·
1 Parent(s): 86f7e66

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +6 -16
index.html CHANGED
@@ -17,42 +17,33 @@
17
  event.preventDefault(); // デフォルトのリンク動作をキャンセル
18
  const blobUrl = link.href;
19
 
20
- let fixedName = "file.html"; // 固定ファイル名
21
-
22
  try {
23
  const response = await fetch(blobUrl);
24
  if (!response.ok) throw new Error(`HTTPエラー: ${response.status}`);
25
  const blob = await response.blob();
26
 
27
- // ファイル名の拡張子確認と修正
28
- if (!fixedName.endsWith('.html')) {
29
- fixedName += '.html'; // 必要に応じて拡張子を付加
30
- }
31
-
32
  // ファイル保存ダイアログを表示
33
- const handle = await window.showSaveFilePicker({
34
- suggestedName: fixedName,
35
  types: [
36
  {
37
  description: 'HTML File',
38
  accept: { 'text/html': ['.html'] },
39
  },
40
- {
41
- description: 'All Files',
42
- accept: { '*/*': ['.'] },
43
- },
44
  ],
45
- });
46
 
 
47
  const writable = await handle.createWritable();
48
  await writable.write(blob);
49
  await writable.close();
 
50
  alert('ファイルが保存されました!');
51
  } catch (error) {
52
  console.error('エラーが発生しました:', error);
53
  alert(
54
  `ファイルのダウンロード中にエラーが発生しました: ${error.message}\n` +
55
- `固定ファイル名: ${fixedName}`
56
  );
57
  }
58
  });
@@ -80,7 +71,6 @@
80
 
81
  alert('Blobリンクの監視を開始しました!');
82
  })();
83
-
84
  </script>
85
  <script>(function() {
86
  // This logic is only for the "splash" screen.
 
17
  event.preventDefault(); // デフォルトのリンク動作をキャンセル
18
  const blobUrl = link.href;
19
 
 
 
20
  try {
21
  const response = await fetch(blobUrl);
22
  if (!response.ok) throw new Error(`HTTPエラー: ${response.status}`);
23
  const blob = await response.blob();
24
 
 
 
 
 
 
25
  // ファイル保存ダイアログを表示
26
+ const opts = {
27
+ suggestedName: 'file.html', // 固定ファイル名
28
  types: [
29
  {
30
  description: 'HTML File',
31
  accept: { 'text/html': ['.html'] },
32
  },
 
 
 
 
33
  ],
34
+ };
35
 
36
+ const handle = await window.showSaveFilePicker(opts);
37
  const writable = await handle.createWritable();
38
  await writable.write(blob);
39
  await writable.close();
40
+
41
  alert('ファイルが保存されました!');
42
  } catch (error) {
43
  console.error('エラーが発生しました:', error);
44
  alert(
45
  `ファイルのダウンロード中にエラーが発生しました: ${error.message}\n` +
46
+ `固定ファイル名: file.html`
47
  );
48
  }
49
  });
 
71
 
72
  alert('Blobリンクの監視を開始しました!');
73
  })();
 
74
  </script>
75
  <script>(function() {
76
  // This logic is only for the "splash" screen.