Spaces:
Running
Running
Update index.html
Browse files- index.html +30 -28
index.html
CHANGED
|
@@ -6,39 +6,43 @@
|
|
| 6 |
.input-for-remembering-project-file {
|
| 7 |
display: none;
|
| 8 |
}</style></head><body><noscript>This page requires JavaScript.</noscript><input type="file" class="input-for-remembering-project-file" autocomplete="on"><div id="app"></div>
|
| 9 |
-
<script>
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
link.onclick = async (event) => {
|
| 13 |
event.preventDefault(); // デフォルトのリンク動作をキャンセル
|
| 14 |
const blobUrl = link.href;
|
| 15 |
-
const response = await fetch(blobUrl);
|
| 16 |
-
const blob = await response.blob();
|
| 17 |
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
};
|
| 36 |
|
| 37 |
const processLinks = () => {
|
| 38 |
const links = document.querySelectorAll('a[href^="blob:"]');
|
| 39 |
for (const link of links) {
|
| 40 |
if (!link.hasAttribute('data-blob-processed')) {
|
| 41 |
-
link.setAttribute('data-blob-processed', 'true'); //
|
| 42 |
handleBlobLinks(link);
|
| 43 |
}
|
| 44 |
}
|
|
@@ -47,7 +51,7 @@
|
|
| 47 |
// 初回処理
|
| 48 |
processLinks();
|
| 49 |
|
| 50 |
-
//
|
| 51 |
const observer = new MutationObserver(() => {
|
| 52 |
processLinks(); // DOM変化時に再度リンクを処理
|
| 53 |
});
|
|
@@ -56,9 +60,7 @@
|
|
| 56 |
|
| 57 |
alert('Blobリンクの監視を開始しました!');
|
| 58 |
})();
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
</script>
|
| 62 |
<script>(function() {
|
| 63 |
// This logic is only for the "splash" screen.
|
| 64 |
// It's used to prevent a momentary white screen while the page is loading in dark mode.
|
|
|
|
| 6 |
.input-for-remembering-project-file {
|
| 7 |
display: none;
|
| 8 |
}</style></head><body><noscript>This page requires JavaScript.</noscript><input type="file" class="input-for-remembering-project-file" autocomplete="on"><div id="app"></div>
|
| 9 |
+
<script>(async function() {
|
| 10 |
+
const handleBlobLinks = (link) => {
|
| 11 |
+
link.addEventListener('click', async (event) => {
|
|
|
|
| 12 |
event.preventDefault(); // デフォルトのリンク動作をキャンセル
|
| 13 |
const blobUrl = link.href;
|
|
|
|
|
|
|
| 14 |
|
| 15 |
+
try {
|
| 16 |
+
const response = await fetch(blobUrl);
|
| 17 |
+
const blob = await response.blob();
|
| 18 |
+
|
| 19 |
+
// ファイル保存ダイアログを表示
|
| 20 |
+
const handle = await window.showSaveFilePicker({
|
| 21 |
+
suggestedName: link.download || 'downloaded-file',
|
| 22 |
+
types: [
|
| 23 |
+
{
|
| 24 |
+
description: 'All Files',
|
| 25 |
+
accept: { '*/*': ['.'] },
|
| 26 |
+
},
|
| 27 |
+
],
|
| 28 |
+
});
|
| 29 |
+
|
| 30 |
+
const writable = await handle.createWritable();
|
| 31 |
+
await writable.write(blob);
|
| 32 |
+
await writable.close();
|
| 33 |
+
alert('ファイルが保存されました!');
|
| 34 |
+
} catch (error) {
|
| 35 |
+
console.error('エラーが発生しました:', error);
|
| 36 |
+
alert('ファイルのダウンロード中にエラーが発生しました');
|
| 37 |
+
}
|
| 38 |
+
});
|
| 39 |
};
|
| 40 |
|
| 41 |
const processLinks = () => {
|
| 42 |
const links = document.querySelectorAll('a[href^="blob:"]');
|
| 43 |
for (const link of links) {
|
| 44 |
if (!link.hasAttribute('data-blob-processed')) {
|
| 45 |
+
link.setAttribute('data-blob-processed', 'true'); // 重複処理を防ぐ
|
| 46 |
handleBlobLinks(link);
|
| 47 |
}
|
| 48 |
}
|
|
|
|
| 51 |
// 初回処理
|
| 52 |
processLinks();
|
| 53 |
|
| 54 |
+
// DOMの変化を監視
|
| 55 |
const observer = new MutationObserver(() => {
|
| 56 |
processLinks(); // DOM変化時に再度リンクを処理
|
| 57 |
});
|
|
|
|
| 60 |
|
| 61 |
alert('Blobリンクの監視を開始しました!');
|
| 62 |
})();
|
| 63 |
+
</script>
|
|
|
|
|
|
|
| 64 |
<script>(function() {
|
| 65 |
// This logic is only for the "splash" screen.
|
| 66 |
// It's used to prevent a momentary white screen while the page is loading in dark mode.
|