This commit is contained in:
Utopiah
2026-08-05 15:15:20 +02:00
parent 9c4edd2ce4
commit 1aebba1ccb
4 changed files with 73 additions and 3 deletions
+25 -2
View File
@@ -1,6 +1,22 @@
console.log('extension loaded kbd');
let blocked = false
let gettingItem
if (typeof browser === 'undefined'){
console.warn('running without extension context, will miss APIs')
} else {
gettingItem = browser.storage.local.get()
gettingItem.then(onGot, onError)
}
function onGot(items){
console.log( items )
}
function onError(error) {
console.log(`Error: ${error}`)
}
let key, modifiers = []
document.addEventListener("keydown", function(event) {
@@ -37,13 +53,20 @@ let userActions = [
{ key: 'x', action: 'autoscroll()'},
{ key: 'b', action: 'history.back()'},
{ key: 'a', action: 'addWiki()'},
{ key: 'n', action: 'firstTab()'},
{ key: 'r', action: 'window.location.reload()'},
{ key: 'h', action: 'alert("r to reload, h for help, etc")'},
// could have example with modifier, e.g. Ctrl or Shift
// or multiple modifiers
{ key: 'h', mods: ['Alt'], action: 'alert("modified help!")'},
]
function firstTab(){
console.log( browser, browser.tabs )
// does not work, somehow browser.tabs remain undefined even with permissions accepted
browser.tabs.query({currentWindow: true}).then( (tabs,n) => {
if (n==0) browser.tabs.update(tab.id, { active: true })
})
}
// from https://gist.github.com/Utopiah/525718c8a60ee2d9e25d7724e9dbb355
const month = [ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ][new Date().getMonth()];
const year = new Date().getFullYear();
+22
View File
@@ -0,0 +1,22 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<h2>PIM</h2>
<form>
<label>URL<input type="text" id="URL" ></label>
<label>author<input type="text" id="author" ></label>
<label>password<input type="text" id="password" ></label>
<button type="submit">Save</button>
</form>
<script src="options.js"></script>
</body>
</html>
+25
View File
@@ -0,0 +1,25 @@
function saveOptions(e) {
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 || "";
}
function onError(error) {
console.log(`Error: ${error}`);
}
var getting = browser.storage.local.get("color");
getting.then(setCurrentChoice, onError);
}
document.addEventListener("DOMContentLoaded", restoreOptions);
document.querySelector("form").addEventListener("submit", saveOptions);
+1 -1
View File
@@ -1,5 +1,5 @@
#!/bin/bash
sed "s/\"version.*/\"version\": \"$(date +%s)\",/" -i manifest.json
zip -r0 kbd.xpi manifest.json kbd.js options.html icons/
zip -r0 kbd.xpi manifest.json kbd.js options.html options.js icons/
kdeconnect-cli -n Pixel --share kbd.xpi