Spaces:
Running
Running
Update index.html
Browse files- index.html +46 -25
index.html
CHANGED
@@ -7,36 +7,57 @@
|
|
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 |
const links = document.querySelectorAll('a[href^="blob:"]');
|
12 |
for (const link of links) {
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
const blob = await fetch(blobURL).then(res => res.blob());
|
18 |
-
const handle = await window.showSaveFilePicker({
|
19 |
-
suggestedName: 'downloaded-file',
|
20 |
-
types: [{
|
21 |
-
description: 'All Files',
|
22 |
-
accept: { '*/*': ['.*'] }
|
23 |
-
}]
|
24 |
-
});
|
25 |
-
const writable = await handle.createWritable();
|
26 |
-
await writable.write(blob);
|
27 |
-
await writable.close();
|
28 |
-
alert('File saved successfully!');
|
29 |
-
} catch (error) {
|
30 |
-
console.error('Error saving file:', error);
|
31 |
-
alert('Failed to save the file.');
|
32 |
-
}
|
33 |
-
};
|
34 |
-
link.href = 'javascript:void(0)';
|
35 |
-
link.textContent += ' (Download)';
|
36 |
}
|
37 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
})();
|
39 |
|
|
|
40 |
</script>
|
41 |
<script>(function() {
|
42 |
// This logic is only for the "splash" screen.
|
|
|
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 |
+
(async function() {
|
11 |
+
const handleBlobLinks = async (link) => {
|
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 |
+
const handle = await window.showSaveFilePicker({
|
20 |
+
suggestedName: link.download || 'downloaded-file',
|
21 |
+
types: [
|
22 |
+
{
|
23 |
+
description: 'All Files',
|
24 |
+
accept: { '*/*': ['.'] },
|
25 |
+
},
|
26 |
+
],
|
27 |
+
});
|
28 |
+
|
29 |
+
const writable = await handle.createWritable();
|
30 |
+
await writable.write(blob);
|
31 |
+
await writable.close();
|
32 |
+
alert('ファイルが保存されました!');
|
33 |
+
};
|
34 |
+
link.href = 'javascript:void(0)';
|
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 |
}
|
45 |
+
};
|
46 |
+
|
47 |
+
// 初回処理
|
48 |
+
processLinks();
|
49 |
+
|
50 |
+
// MutationObserverを使用してDOMの変化を監視
|
51 |
+
const observer = new MutationObserver(() => {
|
52 |
+
processLinks(); // DOM変化時に再度リンクを処理
|
53 |
+
});
|
54 |
+
|
55 |
+
observer.observe(document.body, { childList: true, subtree: true });
|
56 |
+
|
57 |
+
alert('Blobリンクの監視を開始しました!');
|
58 |
})();
|
59 |
|
60 |
+
|
61 |
</script>
|
62 |
<script>(function() {
|
63 |
// This logic is only for the "splash" screen.
|