From 89c4fba7ce43fa06eb4cb0826e928949cbb2819c Mon Sep 17 00:00:00 2001 From: Utopiah Date: Wed, 5 Aug 2026 15:55:15 +0200 Subject: [PATCH] shiftExample --- kbd.js | 9 +++++++-- manifest.json | 4 ++-- options.html | 4 ++++ options.js | 21 ++++++++++++--------- 4 files changed, 25 insertions(+), 13 deletions(-) diff --git a/kbd.js b/kbd.js index e53a93e..dc0beb8 100644 --- a/kbd.js +++ b/kbd.js @@ -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!")'}, ] diff --git a/manifest.json b/manifest.json index 310aba2..c188456 100644 --- a/manifest.json +++ b/manifest.json @@ -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"] diff --git a/options.html b/options.html index 10669d5..05ef50c 100644 --- a/options.html +++ b/options.html @@ -10,8 +10,12 @@

PIM

+
+
+
+
diff --git a/options.js b/options.js index 9ae0ac0..dd050db 100644 --- a/options.js +++ b/options.js @@ -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)