initial 0.1.0 commit
This commit is contained in:
+35
@@ -0,0 +1,35 @@
|
||||
// Tab Park - preferences. The only thing here is the keyboard shortcuts,
|
||||
// which live in Firefox's own shortcuts page. This page shows what is bound
|
||||
// right now and opens that page.
|
||||
|
||||
const $ = id => document.getElementById(id);
|
||||
|
||||
function tuKeys(shortcut) {
|
||||
const fragment = document.createDocumentFragment();
|
||||
if (!shortcut) {
|
||||
fragment.append('Not set');
|
||||
return fragment;
|
||||
}
|
||||
shortcut.split('+').forEach((key, index) => {
|
||||
if (index) fragment.append('+');
|
||||
const kbd = document.createElement('kbd');
|
||||
kbd.textContent = key;
|
||||
fragment.append(kbd);
|
||||
});
|
||||
return fragment;
|
||||
}
|
||||
|
||||
async function tuLoadShortcuts() {
|
||||
const commands = await browser.commands.getAll();
|
||||
const byName = Object.fromEntries(commands.map(command => [command.name, command.shortcut]));
|
||||
$('shortcut-current').replaceChildren(tuKeys(byName['unload-current']));
|
||||
$('shortcut-all').replaceChildren(tuKeys(byName['unload-others']));
|
||||
}
|
||||
|
||||
$('shortcuts').addEventListener('click', () => {
|
||||
browser.commands.openShortcutSettings();
|
||||
});
|
||||
|
||||
browser.commands.onChanged.addListener(tuLoadShortcuts);
|
||||
|
||||
tuLoadShortcuts();
|
||||
Reference in New Issue
Block a user