diff --git a/uploader.html b/uploader.html index addf143..3742619 100644 --- a/uploader.html +++ b/uploader.html @@ -22,11 +22,18 @@ transition: all .2s ease-out; border-radius: .25em; } + #uploader { + display: none; + } + #loading { + font-size: 2em; + } +

Checking...

diff --git a/uploader.js b/uploader.js index 809fa70..99356c0 100644 --- a/uploader.js +++ b/uploader.js @@ -12,6 +12,25 @@ function copyToClipboard(str) { document.body.removeChild(el); } +var http = new XMLHttpRequest(); +http.open("GET", "https://snap.as/api/me", true); +http.onreadystatechange = function() { + if (http.readyState == 4) { + env = JSON.parse(http.responseText); + if (env.code == 200 && typeof env.data !== 'undefined' && env.data != "") { + document.getElementById('loading').style.display = 'none'; + document.getElementById('uploader').style.display = 'block'; + } else { + document.getElementById('loading').innerHTML = 'Log in to Snap.as'; + document.getElementById('login').onclick = function(e) { + e.preventDefault(); + chrome.tabs.create({ url: 'https://snap.as/login' }); + window.close(); + }; + } + } +} +http.send(); Dropzone.options.uploader = { maxFilesize: 16,