shiftExample
This commit is contained in:
@@ -12,6 +12,7 @@ if (typeof browser === 'undefined'){
|
||||
|
||||
function onGot(items){
|
||||
console.log( items )
|
||||
// should instead be used, fow now only useful in addWiki()
|
||||
}
|
||||
|
||||
function onError(error) {
|
||||
@@ -47,14 +48,18 @@ document.addEventListener("keyup", function(event) {
|
||||
})
|
||||
|
||||
// could then grow userActions by the user themselves, save in localStorage, etc without having to rebuild extension
|
||||
// note that i is different from I (which is here capture as I + Shift)
|
||||
// note that i is different from I (which is here captured as I + Shift)
|
||||
let userActions = [
|
||||
{ key: 'r', action: 'window.location.reload()'},
|
||||
{ key: 'x', action: 'autoscroll()'},
|
||||
{ key: 'b', action: 'history.back()'},
|
||||
{ key: 'a', action: 'addWiki()'},
|
||||
{ key: 'n', action: 'firstTab()'},
|
||||
{ key: 'r', action: 'window.location.reload()'},
|
||||
{ key: 'P', mods: ['Shift'], action: 'window.open("https://account.proton.me/")'},
|
||||
{ key: 'i', action: 'window.open("https://fabien.benetou.fr")'},
|
||||
// could be generalize to any bookmarks but needs to be set first, should not be hardcoded like here
|
||||
// for multiple ones would have to handle successive keys, e.g. gtH for go to Home
|
||||
// currently handling single key with modifiers
|
||||
{ key: 'h', action: 'alert("r to reload, h for help, etc")'},
|
||||
{ key: 'h', mods: ['Alt'], action: 'alert("modified help!")'},
|
||||
]
|
||||
|
||||
+2
-2
@@ -2,7 +2,7 @@
|
||||
|
||||
"manifest_version": 2,
|
||||
"name": "keyboard",
|
||||
"version": "1785831306",
|
||||
"version": "1785936598",
|
||||
|
||||
"description": "Adds keyboard capabilities shortuts for content on your local filesystem.",
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
"page": "options.html"
|
||||
},
|
||||
|
||||
"permissions": ["storage"]
|
||||
"permissions": ["storage", "tabs"]
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -10,8 +10,12 @@
|
||||
<h2>PIM</h2>
|
||||
<form>
|
||||
<label>URL<input type="text" id="URL" ></label>
|
||||
<br>
|
||||
<label>author<input type="text" id="author" ></label>
|
||||
<br>
|
||||
<label>password<input type="text" id="password" ></label>
|
||||
<br>
|
||||
<br>
|
||||
<button type="submit">Save</button>
|
||||
</form>
|
||||
|
||||
|
||||
+12
-9
@@ -1,25 +1,28 @@
|
||||
// consider also custom user shortcuts
|
||||
|
||||
function saveOptions(e) {
|
||||
e.preventDefault();
|
||||
e.preventDefault()
|
||||
browser.storage.local.set({
|
||||
URL: document.querySelector("#URL").value,
|
||||
author: document.querySelector("#author").value,
|
||||
password: document.querySelector("#password").value
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
function restoreOptions() {
|
||||
|
||||
function setCurrentChoice(result) {
|
||||
document.querySelector("#password").value = result.color || "";
|
||||
document.querySelector("#author").value = result.author || ""
|
||||
document.querySelector("#password").value = result.password || ""
|
||||
document.querySelector("#URL").value = result.URL || ""
|
||||
}
|
||||
|
||||
function onError(error) {
|
||||
console.log(`Error: ${error}`);
|
||||
console.log(`Error: ${error}`)
|
||||
}
|
||||
|
||||
var getting = browser.storage.local.get("color");
|
||||
getting.then(setCurrentChoice, onError);
|
||||
var getting = browser.storage.local.get("color")
|
||||
getting.then(setCurrentChoice, onError)
|
||||
}
|
||||
|
||||
document.addEventListener("DOMContentLoaded", restoreOptions);
|
||||
document.querySelector("form").addEventListener("submit", saveOptions);
|
||||
document.addEventListener("DOMContentLoaded", restoreOptions)
|
||||
document.querySelector("form").addEventListener("submit", saveOptions)
|
||||
|
||||
Reference in New Issue
Block a user