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

Commit

Permalink
Merge pull request #14 from slgobinath/uget-chrome-wrapper-2
Browse files Browse the repository at this point in the history
Uget chrome wrapper 2
  • Loading branch information
slgobinath committed Feb 25, 2017
2 parents f0b2922 + 72799c5 commit 123692e
Show file tree
Hide file tree
Showing 15 changed files with 142 additions and 76 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ Please test uget-chrome-wrapper on your system and report any issues [here](http
Please test uget-chrome-wrapper and create installers for your operating system

## History
Version 2.0.0 (Under developer testing):
* Migrate to Python 3
* Show uget-chrome-wrapper status in the extension
* Submitted native Opera addon

Version 1.3.3:
* Ctrl + Shift + U to disable uGet Integration extension temporarily
* Option to exclude URLs
Expand Down
4 changes: 2 additions & 2 deletions build/windows/uget-chrome-wrapper.nsi
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
; uget-chrome-wrapper is a tool to integrate uGet Download manager
; with Google Chrome in Linux systems.
; with Google Chrome, Chromium, Vivaldi and Opera in Linux and Windows.

; Copyright (C) 2016 Gobinath

Expand Down Expand Up @@ -148,7 +148,7 @@ Section "uget-chrome-wrapper (required)"

; Update the json file
FileOpen $9 $INSTDIR\com.javahelps.ugetchromewrapper.json w ;Opens a Empty File an fills it
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'
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'
FileClose $9 ;Closes the filled file


Expand Down
81 changes: 53 additions & 28 deletions chrome-extension/background.js → extension/background.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,30 @@
/*
* uget-chrome-wrapper is an extension to integrate uGet Download manager
* with Google Chrome, Chromium and Vivaldi in Linux and Windows.
*
* Copyright (C) 2016 Gobinath
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
* uget-chrome-wrapper is an extension to integrate uGet Download manager
* with Google Chrome, Chromium, Vivaldi and Opera in Linux and Windows.
*
* Copyright (C) 2016 Gobinath
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

var interruptDownloads = true;
var ugetWrapperNotFound = true;
var interruptDownload = false;
var disposition = '';
var hostName = 'com.javahelps.ugetchromewrapper';
var ugetChromeWrapperVersion;
var ugetVersion;
var chromeVersion;
var filter = [];
var keywords = [];
Expand All @@ -46,12 +48,14 @@ try {
chromeVersion = 33;
}
chromeVersion = parseInt(chromeVersion);
sendMessageToHost({ version: "1.1.6" });
sendMessageToHost({
version: "2.0.0"
});

if (localStorage["uget-keywords"]) {
keywords = localStorage["uget-keywords"].split(/[\s,]+/);
} else {
localStorage["uget-keywords"] = '';
localStorage["uget-keywords"] = '';
}


Expand All @@ -61,7 +65,6 @@ if (!localStorage["uget-interrupt"]) {
var interrupt = (localStorage["uget-interrupt"] == "true");
setInterruptDownload(interrupt);
}
console.log(localStorage["uget-interrupt"]);
// Message format to send the download information to the uget-chrome-wrapper
var message = {
url: '',
Expand All @@ -76,10 +79,10 @@ var message = {
// Listen to the key press
chrome.extension.onRequest.addListener(function(request, sender, sendResponse) {
var msg = request.message;
if(msg === 'enable') {
if (msg === 'enable') {
// Temporarily enable
setInterruptDownload(true);
} else if(msg == 'disable') {
} else if (msg == 'disable') {
// Temporarily disable
setInterruptDownload(false);
} else {
Expand All @@ -92,9 +95,23 @@ chrome.extension.onRequest.addListener(function(request, sender, sendResponse) {
function sendMessageToHost(message) {
chrome.runtime.sendNativeMessage(hostName, message, function(response) {
ugetWrapperNotFound = (response == null);
if (!ugetWrapperNotFound && !ugetChromeWrapperVersion) {
ugetChromeWrapperVersion = response.version;
ugetVersion = response.uget;
}
});
}

function getInfo() {
if (ugetWrapperNotFound || !ugetChromeWrapperVersion) {
return "<font color='red'>Error: Unable to connect to the uget-chrome-wrapper</font>";
} else if (!ugetChromeWrapperVersion.startsWith("2.")) {
return "<font color='orange'>Warning: Please update the uget-chrome-wrapper to the latest version</font>";
} else {
return "<font color='green'>Info: Found uGet: " + ugetVersion + " and uget-chrome-wrapper: " + ugetChromeWrapperVersion + "</font>";
}
}

function clearMessage() {
message.url = '';
message.cookies = '';
Expand Down Expand Up @@ -159,7 +176,9 @@ chrome.downloads.onCreated.addListener(function(downloadItem) {
}

chrome.downloads.cancel(downloadItem.id); // Cancel the download
chrome.downloads.erase({ id: downloadItem.id }); // Erase the download from list
chrome.downloads.erase({
id: downloadItem.id
}); // Erase the download from list

clearMessage();
message.url = url;
Expand Down Expand Up @@ -297,7 +316,9 @@ chrome.webRequest.onHeadersReceived.addListener(function(details) {
message.postdata = '';
var scheme = /^https/.test(details.url) ? 'https' : 'http';
if (chromeVersion >= 35) {
return { redirectUrl: "javascript:" };
return {
redirectUrl: "javascript:"
};
} else if (details.frameId === 0) {
chrome.tabs.update(details.tabId, {
url: "javascript:"
Expand Down Expand Up @@ -360,11 +381,15 @@ function isBlackListed(url) {
function setInterruptDownload(interrupt, writeToStorage) {
interruptDownloads = interrupt;
if (interrupt) {
chrome.browserAction.setIcon({ path: "./icon_32.png" });
chrome.browserAction.setIcon({
path: "./icon_32.png"
});
} else {
chrome.browserAction.setIcon({ path: "./icon_disabled_32.png" });
chrome.browserAction.setIcon({
path: "./icon_disabled_32.png"
});
}
if(writeToStorage) {
if (writeToStorage) {
localStorage["uget-interrupt"] = interrupt.toString();
}
}
2 changes: 1 addition & 1 deletion chrome-extension/content.js → extension/content.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* uget-chrome-wrapper is an extension to integrate uGet Download manager
* with Google Chrome, Chromium and Vivaldi in Linux and Windows.
* with Google Chrome, Chromium, Vivaldi and Opera in Linux and Windows.
*
* Copyright (C) 2016 Gobinath
*
Expand Down
File renamed without changes
File renamed without changes
File renamed without changes
Binary file added extension/icon_64.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
5 changes: 3 additions & 2 deletions chrome-extension/manifest.json → extension/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@
"run_at": "document_start"
}
],
"description": "uGet Browser Integration extension replaces default download manager of Google Chrome by uGet Download Manager.",
"description": "uGet Browser Integration extension replaces default download manager by uGet Download Manager.",
"homepage_url": "https://slgobinath.github.io/uget-chrome-wrapper",
"icons": {
"32": "icon_32.png",
"48": "icon_48.png",
"64": "icon_64.png",
"128": "icon_128.png"
},
"manifest_version": 2,
Expand All @@ -42,5 +43,5 @@
"downloads",
"storage"
],
"version": "1.1.6"
"version": "2.0.0"
}
15 changes: 11 additions & 4 deletions chrome-extension/popup.css → extension/popup.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* uget-chrome-wrapper is an extension to integrate uGet Download manager
* with Google Chrome, Chromium and Vivaldi in Linux and Windows.
* with Google Chrome, Chromium, Vivaldi and Opera in Linux and Windows.
*
* Copyright (C) 2016 Gobinath
*
Expand All @@ -20,7 +20,6 @@

body {
overflow-x: hidden;
background: #EFEFEF;
}

input#save {
Expand Down Expand Up @@ -55,11 +54,19 @@ hr {
height: 1px;
border: 0;
border-top: 1px solid #ccc;
margin: 1em 0;
/*margin: 1em 0;*/
padding: 0;
}

label {
#info {
color: #808080;
display: table;
text-align: center;
margin: 0 auto;
line-height: 50%;
}

#label {
font-weight: bold;
color: #4A4A4A;
}
Expand Down
12 changes: 7 additions & 5 deletions chrome-extension/popup.html → extension/popup.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!DOCTYPE html>
<!-- uget-chrome-wrapper is an extension to integrate uGet Download manager
~ with Google Chrome, Chromium and Vivaldi in Linux and Windows.
~ with Google Chrome, Chromium, Vivaldi and Opera in Linux and Windows.
~
~ Copyright (C) 2016 Gobinath
~
Expand All @@ -27,19 +27,21 @@
<body>
<div id="parent-container">
<div id="title-container">
<img id="img-icon" src="icon_32.png" /> <span>uGet Chrome Integration</span>
<img id="img-icon" src="icon_32.png" /> <span>uGet Integration 2.0.0</span>
</div>
<hr>
<label id="info"></label>
<hr>
<div id="controls-container" class="inline">
<label title="Ctrl + Shift + U" for="switch">Interrupt downloads:&nbsp;</label>
<label class="switch">
<label id="label" title="Ctrl + Shift + U" for="switch">Interrupt downloads:&nbsp;</label>
<label id="label" class="switch">
<input id="chk-interrupt" type="checkbox" checked="false">
<div class="slider round"></div>
</label>
</div>
<br>
<div id="controls-container">
<label for="keywords">Exclude URLs containing:</label>
<label id="label" for="keywords">Exclude URLs containing:</label>
<input title="Separate values by comma (Eg: github.com, .jpg)" type="text" id="keywords" name="keywords" size="50" value="" />
</div>
<div id="button-container">
Expand Down
17 changes: 12 additions & 5 deletions chrome-extension/popup.js → extension/popup.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* uget-chrome-wrapper is an extension to integrate uGet Download manager
* with Google Chrome, Chromium and Vivaldi in Linux and Windows.
* with Google Chrome, Chromium, Vivaldi and Opera in Linux and Windows.
*
* Copyright (C) 2016 Gobinath
*
Expand All @@ -18,7 +18,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

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

Expand All @@ -32,12 +32,19 @@ function addBookmark() {
window.close();
}

function updateInfo(info) {
document.getElementById('info').innerHTML = info;
}

// When the popup HTML has loaded
window.addEventListener('load', function(evt) {
// alert(localStorage["uget-interrupt"]);
// alert(typeof localStorage["uget-interrupt"]);
chrome.runtime.getBackgroundPage(function(backgroundPage) {
// alert('hi');
document.getElementById('info').innerHTML = backgroundPage.getInfo();
});

var interrupt = (localStorage["uget-interrupt"] == "true");
document.getElementById('save').addEventListener('click', addBookmark);
document.getElementById('save').addEventListener('click', saveChanges);
document.getElementById('keywords').value = localStorage["uget-keywords"];
document.getElementById('chk-interrupt').checked = interrupt;
});
Loading

0 comments on commit 123692e

Please sign in to comment.