Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Rémi Rigal committed Jun 18, 2020
0 parents commit ed3211d
Show file tree
Hide file tree
Showing 16 changed files with 455 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.idea/

*.zip
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# PyLoad Assistant - Chrome Extension

This is a Chrome extension to monitor and easily add downloads to a [PyLoad](https://github.com/pyload/pyload) server.


## Usage

First makes sure that the IP address and the port of the `PyLoad` server are correctly set in the option page, as well as the user credentials.
These data will only be stored locally using the Chrome storage feature.

The current downloads are available from anywhere.
If the current active tab has a downloadable file, an extra panel will be displayed with a button to start the download.


## Screenshots

![Screenshot1](images/screenshot-1.png)

![Screenshot2](images/screenshot-2.png)

![Screenshot3](images/screenshot-3.png)
10 changes: 10 additions & 0 deletions background.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
chrome.runtime.onInstalled.addListener(function() {
chrome.declarativeContent.onPageChanged.removeRules(undefined, function() {
chrome.declarativeContent.onPageChanged.addRules([{
conditions: [new chrome.declarativeContent.PageStateMatcher({
pageUrl: {schemes: ['http', 'https']},
})],
actions: [new chrome.declarativeContent.ShowPageAction()]
}]);
});
});
7 changes: 7 additions & 0 deletions css/bootstrap.min.css

Large diffs are not rendered by default.

17 changes: 17 additions & 0 deletions css/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
html {
min-width: 500px;
min-height: 160px;
}

body {
min-width: 500px;
min-height: 160px;
max-width: 500px;
padding: 12px 16px;
}

.ellipsis {
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
}
Binary file added images/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/screenshot-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/screenshot-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/screenshot-3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions js/bootstrap.min.js

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions js/jquery-3.5.1.min.js

Large diffs are not rendered by default.

28 changes: 28 additions & 0 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"name": "PyLoad Assistant",
"version": "0.0.1",
"description": "Extension for PyLoad to easily monitor and add downloads",
"permissions": ["activeTab", "declarativeContent", "storage"],
"optional_permissions": ["http://*/", "https://*/"],
"background": {
"scripts": ["background.js"],
"persistent": false
},
"page_action": {
"default_popup": "popup.html",
"default_icon": {
"16": "images/icon.png",
"32": "images/icon.png",
"48": "images/icon.png",
"128": "images/icon.png"
}
},
"icons": {
"16": "images/icon.png",
"32": "images/icon.png",
"48": "images/icon.png",
"128": "images/icon.png"
},
"options_page": "options.html",
"manifest_version": 2
}
43 changes: 43 additions & 0 deletions options.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
</head>
<body>
<div class="text-center h1 m-4">
PyLoad Assistant Options
</div>
<div class="d-flex justify-content-center m-5">
<form>
<div class="form-group">
<label for="serverIp">PyLoad server's IP address</label>
<input type="text" class="form-control" id="serverIp">
</div>
<div class="form-group">
<label for="serverPort">PyLoad server's port</label>
<input type="number" class="form-control" id="serverPort">
</div>
<div class="form-group">
<label for="username">Username</label>
<input type="text" class="form-control" id="username">
</div>
<div class="form-group">
<label for="password">Password</label>
<input type="password" class="form-control" id="password">
</div>
</form>
</div>
<div class="d-flex justify-content-center">
<div class="m-2">
<button id="save" class="btn btn-primary">Save</button>
</div>
</div>
<div class="d-flex justify-content-center">
<div id="saved" class="alert alert-success m-2" hidden>Saved</div>
</div>
</body>

<script type="text/javascript" src="js/jquery-3.5.1.min.js"></script>
<script type="text/javascript" src="js/bootstrap.min.js"></script>
<script src="options.js"></script>
</html>
52 changes: 52 additions & 0 deletions options.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
let usernameInput = document.getElementById('username');
let passwordInput = document.getElementById('password');
let serverIpInput = document.getElementById('serverIp');
let serverPortInput = document.getElementById('serverPort');

let saveButton = document.getElementById('save');
let savedLabel = document.getElementById('saved');


function setSaved() {
savedLabel.hidden = false;
setTimeout(function() {
savedLabel.hidden = true;
}, 3000);
}


saveButton.onclick = function(ev) {
chrome.storage.sync.set({
username: usernameInput.value,
password: passwordInput.value,
serverIp: serverIpInput.value,
serverPort: serverPortInput.value
}, function () {
chrome.permissions.contains({
origins: [`http://${serverIpInput.value}:${serverPortInput.value}/`]
}, function(result) {
console.log(result);
if (result) {
setSaved();
} else {
chrome.permissions.request({
origins: [`http://${serverIpInput.value}:${serverPortInput.value}/`]
}, function(granted) {
console.log(result);
if (granted) {
setSaved();
} else {
alert('Not granting this permission will make the extension unusable.')
}
});
}
});
});
};

chrome.storage.sync.get(['username', 'password', 'serverIp', 'serverPort'], function(data) {
usernameInput.value = data.username || '';
passwordInput.value = data.password || '';
serverIpInput.value = data.serverIp || '172.0.0.1';
serverPortInput.value = data.serverPort || 8001;
});
44 changes: 44 additions & 0 deletions popup.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="css/styles.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
</head>

<body>
<div class="d-flex align-items-center" style="margin-bottom: 8px">
<div class="font-weight-bold">Current Downloads</div>
<div class="ml-auto">
<button id="optionsButton" class="btn">
<i class="fa fa-gear small"></i>
</button>
</div>
</div>
<div id="status">
<div class="d-flex justify-content-center">
<div class="spinner-border text-primary m-3"></div>
</div>
</div>

<div id="pageDownloadDiv" hidden>
<div class="dropdown-divider" style="margin: 20px 0 12px;"></div>

<label class="font-weight-bold">Page Download</label>
<div id="downloadDiv" class="text-center m-2" hidden>
<div id="downloadLabel"></div>
<button type="button" class="btn btn-primary" id="download" style="margin-top: 12px">Start Download</button>
</div>
</div>

<div class="text-center m-3">
<div class="alert alert-danger" id="error" hidden></div>
<div class="alert alert-success" id="success" hidden></div>
</div>

</body>

<script type="text/javascript" src="js/jquery-3.5.1.min.js"></script>
<script type="text/javascript" src="js/bootstrap.min.js"></script>
<script src="popup.js"></script>
</html>
Loading

0 comments on commit ed3211d

Please sign in to comment.