ilk commit
This commit is contained in:
52
browser-extension/background.js
Normal file
52
browser-extension/background.js
Normal 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);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
12
browser-extension/manifest.json
Normal file
12
browser-extension/manifest.json
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"manifest_version": 3,
|
||||
"name": "Download Manager",
|
||||
"version": "1.0.0",
|
||||
"description": "hOLOlu Download Manager'a yönlendir",
|
||||
"permissions": ["downloads", "contextMenus", "storage", "nativeMessaging"],
|
||||
"host_permissions": ["<all_urls>"],
|
||||
"background": { "service_worker": "background.js" },
|
||||
"action": {
|
||||
"default_popup": "popup/popup.html"
|
||||
}
|
||||
}
|
||||
53
browser-extension/popup/popup.html
Normal file
53
browser-extension/popup/popup.html
Normal file
@@ -0,0 +1,53 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Download Manager</title>
|
||||
<style>
|
||||
body {
|
||||
width: 250px;
|
||||
padding: 15px;
|
||||
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
||||
background-color: #f3f3f3;
|
||||
}
|
||||
.header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
.header img {
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
margin-right: 10px;
|
||||
}
|
||||
.header h1 {
|
||||
font-size: 16px;
|
||||
margin: 0;
|
||||
color: #333;
|
||||
}
|
||||
.status {
|
||||
font-size: 13px;
|
||||
color: #666;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.footer {
|
||||
border-top: 1px solid #ddd;
|
||||
padding-top: 10px;
|
||||
font-size: 11px;
|
||||
color: #888;
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="header">
|
||||
<h1>Download Manager</h1>
|
||||
</div>
|
||||
<div class="status">
|
||||
Uzantı aktif. İndirmeler otomatik olarak ana uygulamaya yönlendirilir.
|
||||
</div>
|
||||
<div class="footer">
|
||||
© 2026 hDM Project
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user