diff --git a/js/pyload-api.js b/js/pyload-api.js index e963933..e9f89e3 100644 --- a/js/pyload-api.js +++ b/js/pyload-api.js @@ -1,5 +1,7 @@ +let xhr = null; + function getServerStatus(callback) { - let xhr = new XMLHttpRequest(); + xhr = new XMLHttpRequest(); xhr.open('POST', `${origin}/api/statusServer`, true); xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); xhr.onreadystatechange = function() { diff --git a/js/storage.js b/js/storage.js index 9b6f8f5..8782390 100644 --- a/js/storage.js +++ b/js/storage.js @@ -1,12 +1,16 @@ -let serverPort, serverIp, serverProtocol, origin; +let serverPort, serverIp, serverProtocol, serverPath, origin; function pullStoredData(callback) { chrome.storage.sync.get(['serverIp', 'serverPort', 'serverProtocol'], function(data) { serverIp = data.serverIp || '172.0.0.1'; serverPort = data.serverPort || 8001; + serverPath = data.serverPath || '/'; serverProtocol = data.serverProtocol || 'http'; - origin = `${serverProtocol}://${serverIp}:${serverPort}`; + origin = `${serverProtocol}://${serverIp}:${serverPort}${serverPath}`; + if (origin.endsWith('/')) { + origin = origin.slice(0, origin.length - 1); + } if (callback) callback(data); }); } @@ -20,15 +24,20 @@ function isLoggedIn(callback) { }); } -function setOrigin(ip, port, protocol, callback) { +function setOrigin(ip, port, protocol, path, callback) { serverIp = ip; serverPort = port; serverProtocol = protocol; - origin = `${serverProtocol}://${serverIp}:${serverPort}`; + serverPath = path; + origin = `${serverProtocol}://${serverIp}:${serverPort}${serverPath}`; + if (origin.endsWith('/')) { + origin = origin.slice(0, origin.length - 1); + } chrome.storage.sync.set({ serverIp: serverIp, serverPort: serverPort, - serverProtocol: serverProtocol + serverProtocol: serverProtocol, + serverPath: serverPath }, function () { if (callback) callback(); }); diff --git a/manifest.json b/manifest.json index c1464eb..2ea9541 100644 --- a/manifest.json +++ b/manifest.json @@ -1,6 +1,6 @@ { "name": "Yape", - "version": "1.0.3", + "version": "1.1.0", "description": "Extension for PyLoad to easily monitor and add downloads", "permissions": ["activeTab", "storage", "contextMenus", "scripting"], "host_permissions": ["http://*/", "https://*/"], diff --git a/options.html b/options.html index 7088ee1..106cf8a 100644 --- a/options.html +++ b/options.html @@ -25,15 +25,31 @@ -
+
+
+ + +
+ +
+ Please provide a valid path +
+
+
- + +
+
+ +
+ +
-