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

Commit 9813651

Browse files
committed
Update the extension
1 parent 9c43c31 commit 9813651

File tree

8 files changed

+59
-26
lines changed

8 files changed

+59
-26
lines changed

build/windows/uget-chrome-wrapper.nsi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
; uget-chrome-wrapper is a tool to integrate uGet Download manager
2-
; with Google Chrome in Linux systems.
2+
; with Google Chrome, Chromium, Vivaldi and Opera in Linux and Windows.
33

44
; Copyright (C) 2016 Gobinath
55

@@ -148,7 +148,7 @@ Section "uget-chrome-wrapper (required)"
148148

149149
; Update the json file
150150
FileOpen $9 $INSTDIR\com.javahelps.ugetchromewrapper.json w ;Opens a Empty File an fills it
151-
FileWrite $9 '{"name":"com.javahelps.ugetchromewrapper","description":"Integrate uGet with Google Chrome","path":"$0\\uget-chrome-wrapper.py","type":"stdio","allowed_origins":["chrome-extension://efjgjleilhflffpbnkaofpmdnajdpepi/"]}$\r$\n'
151+
FileWrite $9 '{"name":"com.javahelps.ugetchromewrapper","description":"Integrate uGet with Google Chrome","path":"$0\\uget-chrome-wrapper.py","type":"stdio","allowed_origins":["chrome-extension://efjgjleilhflffpbnkaofpmdnajdpepi/","chrome-extension://akcbnhoidebjpiefdkmaaicfgdpbnoac/"]}$\r$\n'
152152
FileClose $9 ;Closes the filled file
153153

154154

chrome-extension/background.js

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* uget-chrome-wrapper is an extension to integrate uGet Download manager
3-
* with Google Chrome, Chromium and Vivaldi in Linux and Windows.
3+
* with Google Chrome, Chromium, Vivaldi and Opera in Linux and Windows.
44
*
55
* Copyright (C) 2016 Gobinath
66
*
@@ -23,6 +23,8 @@ var ugetWrapperNotFound = true;
2323
var interruptDownload = false;
2424
var disposition = '';
2525
var hostName = 'com.javahelps.ugetchromewrapper';
26+
var ugetChromeWrapperVersion;
27+
var ugetVersion;
2628
var chromeVersion;
2729
var filter = [];
2830
var keywords = [];
@@ -46,7 +48,7 @@ try {
4648
chromeVersion = 33;
4749
}
4850
chromeVersion = parseInt(chromeVersion);
49-
sendMessageToHost({ version: "1.1.6" });
51+
sendMessageToHost({ version: "2.0.0" });
5052

5153
if (localStorage["uget-keywords"]) {
5254
keywords = localStorage["uget-keywords"].split(/[\s,]+/);
@@ -91,9 +93,22 @@ chrome.extension.onRequest.addListener(function(request, sender, sendResponse) {
9193
function sendMessageToHost(message) {
9294
chrome.runtime.sendNativeMessage(hostName, message, function(response) {
9395
ugetWrapperNotFound = (response == null);
96+
if(!ugetWrapperNotFound) {
97+
ugetChromeWrapperVersion = response.version;
98+
ugetVersion = response.uget;
99+
}
94100
});
95101
}
96102

103+
function getInfo() {
104+
if(ugetWrapperNotFound) {
105+
return "<font color='red'>Error: Unable to connect to the uget-chrome-wrapper</font>";
106+
} else if(!ugetChromeWrapperVersion.startsWith("2.")) {
107+
return "<font color='orange'>Warning: Please update the uget-chrome-wrapper to the latest version</font>";
108+
} else {
109+
return "<font color='green'>Info: Found uGet: " + ugetVersion + " and uget-chrome-wrapper: " + ugetChromeWrapperVersion + "</font>";
110+
}
111+
}
97112
function clearMessage() {
98113
message.url = '';
99114
message.cookies = '';

chrome-extension/content.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* uget-chrome-wrapper is an extension to integrate uGet Download manager
3-
* with Google Chrome, Chromium and Vivaldi in Linux and Windows.
3+
* with Google Chrome, Chromium, Vivaldi and Opera in Linux and Windows.
44
*
55
* Copyright (C) 2016 Gobinath
66
*

chrome-extension/icon_64.png

4.1 KB
Loading

chrome-extension/popup.css

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* uget-chrome-wrapper is an extension to integrate uGet Download manager
3-
* with Google Chrome, Chromium and Vivaldi in Linux and Windows.
3+
* with Google Chrome, Chromium, Vivaldi and Opera in Linux and Windows.
44
*
55
* Copyright (C) 2016 Gobinath
66
*
@@ -20,7 +20,6 @@
2020

2121
body {
2222
overflow-x: hidden;
23-
background: #EFEFEF;
2423
}
2524

2625
input#save {
@@ -55,11 +54,19 @@ hr {
5554
height: 1px;
5655
border: 0;
5756
border-top: 1px solid #ccc;
58-
margin: 1em 0;
57+
/*margin: 1em 0;*/
5958
padding: 0;
6059
}
6160

62-
label {
61+
#info {
62+
color: #808080;
63+
display: table;
64+
text-align: center;
65+
margin: 0 auto;
66+
line-height: 50%;
67+
}
68+
69+
#label {
6370
font-weight: bold;
6471
color: #4A4A4A;
6572
}

chrome-extension/popup.html

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<!DOCTYPE html>
22
<!-- uget-chrome-wrapper is an extension to integrate uGet Download manager
3-
~ with Google Chrome, Chromium and Vivaldi in Linux and Windows.
3+
~ with Google Chrome, Chromium, Vivaldi and Opera in Linux and Windows.
44
~
55
~ Copyright (C) 2016 Gobinath
66
~
@@ -27,19 +27,21 @@
2727
<body>
2828
<div id="parent-container">
2929
<div id="title-container">
30-
<img id="img-icon" src="icon_32.png" /> <span>uGet Chrome Integration</span>
30+
<img id="img-icon" src="icon_32.png" /> <span>uGet Integration 2.0.0</span>
3131
</div>
3232
<hr>
33+
<label id="info"></label>
34+
<hr>
3335
<div id="controls-container" class="inline">
34-
<label title="Ctrl + Shift + U" for="switch">Interrupt downloads:&nbsp;</label>
35-
<label class="switch">
36+
<label id="label" title="Ctrl + Shift + U" for="switch">Interrupt downloads:&nbsp;</label>
37+
<label id="label" class="switch">
3638
<input id="chk-interrupt" type="checkbox" checked="false">
3739
<div class="slider round"></div>
3840
</label>
3941
</div>
4042
<br>
4143
<div id="controls-container">
42-
<label for="keywords">Exclude URLs containing:</label>
44+
<label id="label" for="keywords">Exclude URLs containing:</label>
4345
<input title="Separate values by comma (Eg: github.com, .jpg)" type="text" id="keywords" name="keywords" size="50" value="" />
4446
</div>
4547
<div id="button-container">

chrome-extension/popup.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* uget-chrome-wrapper is an extension to integrate uGet Download manager
3-
* with Google Chrome, Chromium and Vivaldi in Linux and Windows.
3+
* with Google Chrome, Chromium, Vivaldi and Opera in Linux and Windows.
44
*
55
* Copyright (C) 2016 Gobinath
66
*
@@ -18,7 +18,7 @@
1818
* along with this program. If not, see <http://www.gnu.org/licenses/>.
1919
*/
2020

21-
function addBookmark() {
21+
function saveChanges() {
2222
var keywords = document.getElementById("keywords").value;
2323
var interrupt = document.getElementById('chk-interrupt').checked;
2424

@@ -32,12 +32,19 @@ function addBookmark() {
3232
window.close();
3333
}
3434

35+
function updateInfo(info) {
36+
document.getElementById('info').innerHTML = info;
37+
}
38+
3539
// When the popup HTML has loaded
3640
window.addEventListener('load', function(evt) {
37-
// alert(localStorage["uget-interrupt"]);
38-
// alert(typeof localStorage["uget-interrupt"]);
41+
chrome.runtime.getBackgroundPage(function(backgroundPage) {
42+
// alert('hi');
43+
document.getElementById('info').innerHTML = backgroundPage.getInfo();
44+
});
45+
3946
var interrupt = (localStorage["uget-interrupt"] == "true");
40-
document.getElementById('save').addEventListener('click', addBookmark);
47+
document.getElementById('save').addEventListener('click', saveChanges);
4148
document.getElementById('keywords').value = localStorage["uget-keywords"];
4249
document.getElementById('chk-interrupt').checked = interrupt;
4350
});

uget-chrome-wrapper/bin/uget-chrome-wrapper

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python3
22

33
# uget-chrome-wrapper is a tool to integrate uGet Download manager
4-
# with Google Chrome in Linux systems.
4+
# with Google Chrome, Chromium, Vivaldi and Opera in Linux and Windows.
55

66
# Copyright (C) 2016 Gobinath
77

@@ -19,14 +19,13 @@
1919
# along with this program. If not, see <http://www.gnu.org/licenses/>.
2020

2121
# sudo apt install python3-urllib3
22-
import struct, sys, threading, logging, json, urllib
23-
from subprocess import call
22+
import struct, sys, threading, logging, json, urllib, subprocess
2423
from urllib.parse import urlparse
2524
from os.path import splitext, basename, join, expanduser
2625
from mimetypes import guess_extension
2726

2827
UGET_COMMAND = "uget-gtk"
29-
VERSION = "1.3.4"
28+
VERSION = "2.0.0"
3029

3130
logger = logging.getLogger()
3231
# log_file_path = join(expanduser('~'), 'uget-chrome-wrapper.log')
@@ -99,7 +98,10 @@ def read_message():
9998

10099
if text:
101100
if not 'url' in text:
102-
send_message('{"enable": true, "version": "' + VERSION + '"}')
101+
uget_version = subprocess.run(UGET_COMMAND + " --version", shell=True, stdout=subprocess.PIPE, universal_newlines=True).stdout;
102+
uget_version = uget_version.replace('uGet', '').replace('for GTK+', '').strip()
103+
logger.debug('uGet version: ' + uget_version)
104+
send_message('{"enable": true, "version": "' + VERSION + '", "uget": "' + uget_version + '"}')
103105
return
104106

105107
send_message('{"state": "accepted"}')
@@ -113,9 +115,9 @@ def read_message():
113115
if not filename:
114116
filename = extract_file_name(url)
115117
if referer:
116-
call([UGET_COMMAND, "--http-referer=" + referer, "--filename=" + filename, url])
118+
subprocess.call([UGET_COMMAND, "--http-referer=" + referer, "--filename=" + filename, url])
117119
else:
118-
call([UGET_COMMAND, "--filename=" + filename, url])
120+
subprocess.call([UGET_COMMAND, "--filename=" + filename, url])
119121

120122
sys.exit(0)
121123

0 commit comments

Comments
 (0)