Skip to content

Commit 3dd4d9b

Browse files
committed
Add debug code
1 parent 2c93852 commit 3dd4d9b

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

chrome/player/network/DownloadEntry.mjs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,4 +179,28 @@ export class DownloadEntry {
179179
getDataSize() {
180180
return this.dataSize;
181181
}
182+
183+
// debug
184+
async downloadFile() {
185+
const data = await this.getData();
186+
187+
// if it's a blob, convert it to a URL
188+
if (data instanceof Blob) {
189+
const url = URL.createObjectURL(data);
190+
const a = document.createElement('a');
191+
a.href = url;
192+
a.download = this.url.split('/').pop() || 'download';
193+
document.body.appendChild(a);
194+
a.click();
195+
document.body.removeChild(a);
196+
URL.revokeObjectURL(url);
197+
} else {
198+
const a = document.createElement('a');
199+
a.href = 'data:application/octet-stream;base64,' + btoa(data);
200+
a.download = this.url.split('/').pop() || 'download';
201+
document.body.appendChild(a);
202+
a.click();
203+
document.body.removeChild(a);
204+
}
205+
}
182206
}

0 commit comments

Comments
 (0)