mirror of
https://github.com/andwati/kget-capture.git
synced 2026-10-18 11:12:57 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a2cd4184e3
|
@@ -83,9 +83,11 @@ git push origin v1.0.0
|
||||
|
||||
## Known limitations
|
||||
|
||||
- **`blob:`/`data:` URLs can't be captured.** There's no real network URL to
|
||||
hand to KGet, so these downloads proceed normally through Chrome (a console
|
||||
warning is logged in the extension's service worker).
|
||||
- **`blob:`/`data:`/`file:`/`filesystem:` URLs can't be captured.** There's
|
||||
no real network URL to hand to KGet — this includes saving a page you
|
||||
navigated to directly via `file://` (Ctrl+S on it is still a "download" as
|
||||
far as Chrome is concerned) — so these downloads proceed normally through
|
||||
Chrome (a console warning is logged in the extension's service worker).
|
||||
- **Auto-capture has a brief head start.** Manifest V3 removed blocking
|
||||
`webRequest`, so Chrome begins the download before the extension can cancel
|
||||
it. A small/partial temp file may transiently appear before it's erased.
|
||||
|
||||
+18
-2
@@ -11,6 +11,18 @@ async function refreshBadge() {
|
||||
updateBadge(autoCaptureEnabled);
|
||||
}
|
||||
|
||||
// KGet is a network download manager -- it can't "download" a URL that's
|
||||
// already local (or embedded in the page), so don't hand it these schemes.
|
||||
// file: shows up when saving a page you navigated to directly (Ctrl+S on a
|
||||
// file:// URL is still a "download" as far as chrome.downloads is
|
||||
// concerned), and KGet's addTransfer rejects it with a confusing
|
||||
// "protocol is not supported" dialog if we try.
|
||||
const UNSUPPORTED_SCHEMES = ["blob:", "data:", "file:", "filesystem:"];
|
||||
|
||||
function isCapturableUrl(url) {
|
||||
return !UNSUPPORTED_SCHEMES.some((scheme) => url.startsWith(scheme));
|
||||
}
|
||||
|
||||
function sendToKGet(url, filename) {
|
||||
chrome.runtime.sendNativeMessage(
|
||||
NATIVE_HOST,
|
||||
@@ -44,6 +56,10 @@ chrome.contextMenus.onClicked.addListener((info) => {
|
||||
if (info.menuItemId !== MENU_ID) return;
|
||||
const url = info.linkUrl || info.srcUrl;
|
||||
if (!url) return;
|
||||
if (!isCapturableUrl(url)) {
|
||||
console.warn("[kget-capture] cannot hand a local/embedded URL to KGet:", url);
|
||||
return;
|
||||
}
|
||||
sendToKGet(url, null);
|
||||
});
|
||||
|
||||
@@ -63,8 +79,8 @@ async function captureDownload(item) {
|
||||
if (!autoCaptureEnabled) return;
|
||||
|
||||
const url = item.finalUrl || item.url;
|
||||
if (url.startsWith("blob:") || url.startsWith("data:")) {
|
||||
console.warn("[kget-capture] cannot redirect blob:/data: URL, letting Chrome handle it:", url);
|
||||
if (!isCapturableUrl(url)) {
|
||||
console.warn("[kget-capture] cannot hand a local/embedded URL to KGet, letting Chrome handle it:", url);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"manifest_version": 3,
|
||||
"name": "KGet Capture",
|
||||
"version": "1.0.2",
|
||||
"version": "1.0.3",
|
||||
"description": "Send browser downloads to KGet (KDE Download Manager) on Linux.",
|
||||
"key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAtM1nFg5pPd3UBzynUJHj6aUy7bjudZaX9AQTWGMqAX3fXylw1lubSzP1/BaS9ivvgOJg/loyEgzEZlcNPzblFVlg8BqEJ3tntdk2OzYvUs0pUdcPzzyjso9TykCkUUTI7ev8JkreW/FYlinfvNwSYN4/c1s3h8/I6XHtxOdmO1G3bS98+BQaXPldbDmxoKwyWR8u1f8gTO2Mg3GY4BHau3RWf1kgtNzh20p9wE3sEFdWkFu7ArgRCIrWLh6m3O6lolnHQSCWPwtOTx893Qkp9Eu6FwUnoWc8rsYx8sqa0eNCTCS6Kjr1Iu3yEJ5y9390jUiDZTQ/c62ueCTQaYv2bwIDAQAB",
|
||||
"permissions": ["downloads", "contextMenus", "storage", "nativeMessaging"],
|
||||
|
||||
Reference in New Issue
Block a user