-
Notifications
You must be signed in to change notification settings - Fork 2
/
common.js
49 lines (40 loc) · 1.14 KB
/
common.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
const PREFIX_PRESET = "preset-"; // Must match the one in options.js
async function applyPreset(presetId)
{
console.log("(common) applying preset: " + presetId);
let storage = await browser.storage.local.get("presets");
let presets = storage.presets;
for(let i = 0;i < presets.length;i++)
{
if(presets[i].id == presetId)
{
await resizeWindow(presets[i].width,presets[i].height);
break;
}
}
}
async function resizeWindow(newWidth, newHeight)
{
console.log("(common) resizing to: " + newWidth + "x" + newHeight);
let updateInfo = {
"width": parseInt(newWidth),
"height": parseInt(newHeight)
};
let currentWindow = await browser.windows.getCurrent();
await browser.windows.update(currentWindow.id, updateInfo);
}
async function getShortcutKey(commandName)
{
console.log("(common) retrieving shortcut for " + commandName);
let shortcutKey = "(none)";
let commands = await browser.commands.getAll();
for(let command of commands)
{
if(command.name == commandName)
{
shortcutKey = command.shortcut;
break;
}
}
return shortcutKey;
}