diff --git a/js/pyload-api.js b/js/pyload-api.js index e9f89e3..5a3585b 100644 --- a/js/pyload-api.js +++ b/js/pyload-api.js @@ -7,20 +7,28 @@ function getServerStatus(callback) { xhr.onreadystatechange = function() { if (xhr.readyState === 4) { try { + if (xhr.status === 404) { + if (callback) callback(false, false, 'Server not found'); + return; + } const response = JSON.parse(xhr.responseText); - if (response.hasOwnProperty('error')) { - if (callback) callback(false, response.error); - } else { - if (callback) callback(true, null, response); + if (xhr.status === 200) { + if (callback) callback(true, false, null, response); + } else if (xhr.status === 403) { + if (callback) callback(false, true, 'Unauthorized', response); + } else if (response.hasOwnProperty('error')) { + if (callback) callback(false, false, response.error); + } else { + if (callback) callback(false, false, null, response); } } catch { - if (callback) callback(false, 'Server unreachable'); + if (callback) callback(false, false, 'Server unreachable'); } } } xhr.timeout = 5000; xhr.ontimeout = function() { - if (callback) callback(false, 'Server unreachable'); + if (callback) callback(false, false, 'Server unreachable'); } xhr.send(); } diff --git a/js/storage.js b/js/storage.js index 8782390..928c064 100644 --- a/js/storage.js +++ b/js/storage.js @@ -16,10 +16,9 @@ function pullStoredData(callback) { } function isLoggedIn(callback) { - getServerStatus(function(success) { + getServerStatus(function(success, unauthorized, error, response) { if (callback) { - if (success) callback(true); - else callback(false); + callback(success, unauthorized, error, response); } }); } diff --git a/manifest.json b/manifest.json index 2ea9541..3d991d5 100644 --- a/manifest.json +++ b/manifest.json @@ -1,6 +1,6 @@ { "name": "Yape", - "version": "1.1.0", + "version": "1.1.1", "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 106cf8a..95d8c08 100644 --- a/options.html +++ b/options.html @@ -23,13 +23,15 @@