Dropbox workaround for Firefox on Android
This commit is contained in:
parent
b40849acad
commit
16585331d4
|
@ -110,6 +110,9 @@
|
|||
"js": ["content/install-hook-usercss.js"]
|
||||
}
|
||||
],
|
||||
"web_accessible_resources": [
|
||||
"/sync/dropbox-oauth.html"
|
||||
],
|
||||
"browser_action": {
|
||||
"default_icon": {
|
||||
"16": "/images/icon/16w.png",
|
||||
|
|
11
sync/dropbox-auth-receiver.js
Normal file
11
sync/dropbox-auth-receiver.js
Normal file
|
@ -0,0 +1,11 @@
|
|||
/* global chromeLocal */
|
||||
'use strict';
|
||||
|
||||
window.onload = () => {
|
||||
const params = new URLSearchParams(new URL(location.href).hash.substr(1));
|
||||
/* it uses browser direct here because it supports just firefox yet */
|
||||
chromeLocal.setValue('dropbox_access_token', params.get('access_token'))
|
||||
.then(() => {
|
||||
window.location.href = window.location.origin + '/manage.html';
|
||||
});
|
||||
}
|
12
sync/dropbox-oauth.html
Normal file
12
sync/dropbox-oauth.html
Normal file
|
@ -0,0 +1,12 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>OAuth Receiver</title>
|
||||
<script async defer src="../js/storage-util.js"></script>
|
||||
<script async defer src="./dropbox-auth-receiver.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
|
@ -3,7 +3,8 @@
|
|||
$ $create t chromeLocal API getOwnTab */
|
||||
'use strict';
|
||||
|
||||
const DROPBOX_API_KEY = 'zg52vphuapvpng9';
|
||||
// const DROPBOX_API_KEY = 'zg52vphuapvpng9';
|
||||
const DROPBOX_API_KEY = 'uyfixgzre8v1bkg';
|
||||
const FILENAME_ZIP_FILE = 'stylus.json';
|
||||
const DROPBOX_FILE = 'stylus.zip';
|
||||
const API_ERROR_STATUS_FILE_NOT_FOUND = 409;
|
||||
|
@ -35,6 +36,11 @@ function requestDropboxAccessToken() {
|
|||
clientId: DROPBOX_API_KEY,
|
||||
fetch
|
||||
});
|
||||
const isFirefoxAndroid = /Android/.test(navigator.userAgent) && /Mozilla/.test(navigator.userAgent);
|
||||
if (isFirefoxAndroid) {
|
||||
window.location.href = client.getAuthenticationUrl(window.location.origin + '/sync/dropbox-oauth.html');
|
||||
return;
|
||||
}
|
||||
const authUrl = client.getAuthenticationUrl(getRedirectUrlAuthFlow());
|
||||
return launchWebAuthFlow({url: authUrl, interactive: true})
|
||||
.then(urlReturned => {
|
||||
|
@ -51,9 +57,9 @@ function uploadFileDropbox(client, stylesText) {
|
|||
$('#sync-dropbox-export').onclick = () => {
|
||||
const mode = localStorage.installType;
|
||||
const title = t('syncDropboxStyles');
|
||||
const text = mode === 'normal' ? t('connectingDropbox') : t('connectingDropboxNotAllowed');
|
||||
messageProgressBar({title, text});
|
||||
if (mode !== 'normal') return;
|
||||
// const text = mode === 'normal' ? t('connectingDropbox') : t('connectingDropboxNotAllowed');
|
||||
// messageProgressBar({title, text});
|
||||
// if (mode !== 'normal') return;
|
||||
|
||||
hasDropboxAccessToken()
|
||||
.then(token => token || requestDropboxAccessToken())
|
||||
|
@ -125,9 +131,9 @@ $('#sync-dropbox-export').onclick = () => {
|
|||
$('#sync-dropbox-import').onclick = () => {
|
||||
const mode = localStorage.installType;
|
||||
const title = t('retrieveDropboxSync');
|
||||
const text = mode === 'normal' ? t('connectingDropbox') : t('connectingDropboxNotAllowed');
|
||||
messageProgressBar({title, text});
|
||||
if (mode !== 'normal') return;
|
||||
// const text = mode === 'normal' ? t('connectingDropbox') : t('connectingDropboxNotAllowed');
|
||||
// messageProgressBar({title, text});
|
||||
// if (mode !== 'normal') return;
|
||||
|
||||
hasDropboxAccessToken()
|
||||
.then(token => token || requestDropboxAccessToken())
|
||||
|
|
Loading…
Reference in New Issue
Block a user