Skip to content

Commit

Permalink
fix: Intercepted stream download content causing unsupported protocol…
Browse files Browse the repository at this point in the history
… error
  • Loading branch information
krau committed Jul 19, 2024
1 parent 9232a72 commit f5d96f4
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ chrome.storage.onChanged.addListener((changes) => {
});

chrome.downloads.onDeterminingFilename.addListener(async function (item) {
if (item.mime === "application/octet-stream") {
return;
}
await initStorage;
if (!Settings.enabled) {
return;
Expand Down Expand Up @@ -107,6 +110,9 @@ chrome.contextMenus.onClicked.addListener(async function (info, tab) {
message: '无法获取下载链接',
});
}
chrome.action.setBadgeText({
text: '🔗',
});
const resolveResult = await client.resolve({
url: downloadUrl,
extra: {
Expand All @@ -121,6 +127,9 @@ chrome.contextMenus.onClicked.addListener(async function (info, tab) {
name: resolveResult.res.files[0].name
}
})
chrome.action.setBadgeText({
text: '',
});
if (Settings.enableNotification) {
await sendSuccessNotification('文件大小: ' + (resolveResult.res.files[0].size / (1024 * 1024)).toFixed(2) + 'MB');
}
Expand Down

0 comments on commit f5d96f4

Please sign in to comment.