ilk commit

This commit is contained in:
hOLOlu
2026-05-04 01:19:04 +03:00
commit 5f33557f2d
2072 changed files with 75437 additions and 0 deletions

View File

@@ -0,0 +1,52 @@
const NATIVE_HOST = "com.downloadmanager.bridge";
const interceptExtensions = [
"exe","msi","zip","rar","7z","tar","gz","iso",
"mp4","mkv","avi","mp3","flac","wav",
"pdf","docx","xlsx","pptx"
];
chrome.runtime.onInstalled.addListener(() => {
chrome.contextMenus.create({
id: "dm-link",
title: "Download Manager ile İndir",
contexts: ["link"]
});
});
chrome.downloads.onCreated.addListener((item) => {
const ext = item.filename?.split(".").pop()?.toLowerCase() ?? "";
if (!interceptExtensions.includes(ext)) return;
chrome.downloads.cancel(item.id, () => {
console.log("İndirme yakalandı, bridge'e gönderiliyor:", item.url);
chrome.runtime.sendNativeMessage(NATIVE_HOST, {
action: "add_download",
url: item.url,
filename: item.filename,
referrer: item.referrer ?? ""
}, (response) => {
if (chrome.runtime.lastError) {
console.error("Bridge Hatası:", chrome.runtime.lastError.message);
} else {
console.log("Bridge Yanıtı:", response);
}
});
});
});
chrome.contextMenus.onClicked.addListener((info, tab) => {
if (info.menuItemId === "dm-link") {
console.log("Context menu tıklandı, bridge'e gönderiliyor:", info.linkUrl);
chrome.runtime.sendNativeMessage(NATIVE_HOST, {
action: "add_download",
url: info.linkUrl
}, (response) => {
if (chrome.runtime.lastError) {
console.error("Bridge Hatası:", chrome.runtime.lastError.message);
} else {
console.log("Bridge Yanıtı:", response);
}
});
}
});