Skip to content
This repository was archived by the owner on Mar 22, 2018. It is now read-only.

Commit 1f99a5f

Browse files
committed
Add download option to context menu
1 parent 354cdd4 commit 1f99a5f

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

chrome-extension/background.js

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ try {
2828
chromeVersion = 33;
2929
}
3030
chromeVersion = parseInt(chromeVersion);
31-
sendMessageToHost({ version: "1.1.2" });
31+
sendMessageToHost({ version: "1.1.3" });
3232

3333

3434
// Message format to send the download information to the uget-chrome-wrapper
@@ -73,6 +73,27 @@ function postParams(source) {
7373
}
7474
return array.join('&');
7575
}
76+
77+
// Add to Chrome context menu
78+
chrome.contextMenus.create(
79+
{
80+
title: 'Download with uGet',
81+
id: "download_with_uget",
82+
contexts: ['link']
83+
}
84+
);
85+
86+
chrome.contextMenus.onClicked.addListener(function (info, tab) {
87+
"use strict";
88+
if (info.menuItemId === "download_with_uget") {
89+
clearMessage();
90+
message.url = info['linkUrl'];
91+
message.referrer = info['pageUrl'];
92+
sendMessageToHost(message);
93+
clearMessage();
94+
}
95+
});
96+
7697
chrome.webRequest.onBeforeRequest.addListener(function(details) {
7798
if (details.method == 'POST') {
7899
message.postdata = postParams(details.requestBody.formData);

chrome-extension/manifest.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@
3636
"<all_urls>",
3737
"webRequest",
3838
"webRequestBlocking",
39-
"nativeMessaging"
39+
"nativeMessaging",
40+
"contextMenus"
4041
],
41-
"version": "1.1.2"
42+
"version": "1.1.3"
4243
}

0 commit comments

Comments
 (0)