-
Notifications
You must be signed in to change notification settings - Fork 20
/
speeddial-shortcuts.js
52 lines (42 loc) · 1.75 KB
/
speeddial-shortcuts.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
50
51
52
//Keyboard shortcuts for SpeedDial
//Горячие клавиши для элементов экспресс-панели
//TODO: cannot display category name :(
vivaldi.jdhooks.hookModuleExport("vivaldiSettings", "default", exports => {
let oldGetDefault = exports.getDefault
exports.getDefault = name => {
if (typeof name == "string" && name.substr(0, 23) == "COMMAND_OPEN_SPEEDDIAL_") return { showInQC: true }
return oldGetDefault(name)
}
return exports
})
vivaldi.jdhooks.hookModuleExport('_CommandManager', "default", exports => {
function openSpeedDialItem(i) {
const UrlFieldActions = vivaldi.jdhooks.require("_UrlFieldActions")
const PrefKeys = vivaldi.jdhooks.require("_PrefKeys")
const PrefCache = vivaldi.jdhooks.require('PrefsCache')
const sdi = vivaldi.jdhooks.require('_BookmarkStore').getSpeeddialFolders()
if (sdi && sdi[0] && sdi[0].children[i - 1]) {
UrlFieldActions.go([sdi[0].children[i - 1].url], {
inCurrent: !PrefCache.get(PrefKeys.kQuickCommandsOpenUrlInNewTab),
addTypedHistory: false,
addTypedSearchHistory: false,
enableSearch: true
})
}
}
let cmds = exports.getCommands()
for (let i = 1; i < 10; i++) {
(function (x) {
cmds.push({
name: "COMMAND_OPEN_SPEEDDIAL_" + x,
action: () => openSpeedDialItem(x),
label: "Open SpeedDial item " + x,
labelEnglish: "Open SpeedDial item " + x,
category: 'CATEGORY_COMMAND_HOOK',
showInQC: true
})
}
)(i)
}
return exports
})