feat: navigate with client app using keyboard

Closes #168.
pull/270/head
dessant 4 years ago
parent 39cf3c02ef
commit d34f5fa8b7

@ -189,6 +189,11 @@
"description": "Title of the option." "description": "Title of the option."
}, },
"optionTitle_navigateWithKeyboard": {
"message": "Navigate with keyboard",
"description": "Title of the option."
},
"optionTitle_autoUpdateClientApp": { "optionTitle_autoUpdateClientApp": {
"message": "Auto-update client app", "message": "Auto-update client app",
"description": "Title of the option." "description": "Title of the option."

@ -126,6 +126,18 @@
</v-form-field> </v-form-field>
</div> </div>
<div
class="option"
v-if="clientAppVerified && options.simulateUserInput"
>
<v-form-field
input-id="nc"
:label="getText('optionTitle_navigateWithKeyboard')"
>
<v-switch id="nc" v-model="options.navigateWithKeyboard"></v-switch>
</v-form-field>
</div>
<div class="option" v-if="clientAppInstalled"> <div class="option" v-if="clientAppInstalled">
<v-form-field <v-form-field
input-id="auc" input-id="auc"
@ -294,7 +306,8 @@ export default {
loadEnglishChallenge: false, loadEnglishChallenge: false,
tryEnglishSpeechModel: false, tryEnglishSpeechModel: false,
simulateUserInput: false, simulateUserInput: false,
autoUpdateClientApp: false autoUpdateClientApp: false,
navigateWithKeyboard: false
} }
}; };
}, },

@ -236,10 +236,15 @@ async function solve(simulateUserInput, clickEvent) {
return; return;
} }
const navigateWithKeyboard = await storage.get(
'navigateWithKeyboard',
'sync'
);
let browserBorder; let browserBorder;
let useMouse = true; let useMouse = true;
if (simulateUserInput) { if (simulateUserInput) {
if (clickEvent.clientX || clickEvent.clientY) { if (!navigateWithKeyboard && (clickEvent.clientX || clickEvent.clientY)) {
browserBorder = await getBrowserBorder(clickEvent); browserBorder = await getBrowserBorder(clickEvent);
} else { } else {
useMouse = false; useMouse = false;

@ -0,0 +1,27 @@
import browser from 'webextension-polyfill';
const message = 'Add navigateWithKeyboard';
const revision = 'Lj3MYlSr4L';
const downRevision = 'DlgF14Chrh';
const storage = browser.storage.local;
async function upgrade() {
const changes = {
navigateWithKeyboard: false
};
changes.storageVersion = revision;
return storage.set(changes);
}
async function downgrade() {
const changes = {};
await storage.remove('navigateWithKeyboard');
changes.storageVersion = downRevision;
return storage.set(changes);
}
export {message, revision, upgrade, downgrade};

@ -7,6 +7,7 @@
"ZtLMLoh1ag", "ZtLMLoh1ag",
"t335iRDhZ8", "t335iRDhZ8",
"X3djS8vZC", "X3djS8vZC",
"DlgF14Chrh" "DlgF14Chrh",
"Lj3MYlSr4L"
] ]
} }

@ -0,0 +1,27 @@
import browser from 'webextension-polyfill';
const message = 'Add navigateWithKeyboard';
const revision = 'Lj3MYlSr4L';
const downRevision = 'DlgF14Chrh';
const storage = browser.storage.sync;
async function upgrade() {
const changes = {
navigateWithKeyboard: false
};
changes.storageVersion = revision;
return storage.set(changes);
}
async function downgrade() {
const changes = {};
await storage.remove('navigateWithKeyboard');
changes.storageVersion = downRevision;
return storage.set(changes);
}
export {message, revision, upgrade, downgrade};

@ -7,6 +7,7 @@
"ZtLMLoh1ag", "ZtLMLoh1ag",
"t335iRDhZ8", "t335iRDhZ8",
"X3djS8vZC", "X3djS8vZC",
"DlgF14Chrh" "DlgF14Chrh",
"Lj3MYlSr4L"
] ]
} }

@ -9,7 +9,8 @@ const optionKeys = [
'loadEnglishChallenge', 'loadEnglishChallenge',
'tryEnglishSpeechModel', 'tryEnglishSpeechModel',
'simulateUserInput', 'simulateUserInput',
'autoUpdateClientApp' 'autoUpdateClientApp',
'navigateWithKeyboard'
]; ];
const clientAppPlatforms = [ const clientAppPlatforms = [

Loading…
Cancel
Save