-
Notifications
You must be signed in to change notification settings - Fork 3
/
复制命令时通知导入.ini
53 lines (53 loc) · 2.01 KB
/
复制命令时通知导入.ini
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
53
[Command]
Name=\x590d\x5236\x43opyQ\x547d\x4ee4\x65f6\x5f39\x51fa\x901a\x77e5
Match=^\\[Commands?\\]|https?://github\\.com/.*/copyq-commands/blob/.*\\.ini
Command="
copyq:
// Imports raw commands code (starting with [Command] or [Commands])
// or from a link ('https://github.com/**/copyq-commands/blob/**.ini').
var timeOutSeconds = 10
var rawDataUrlPrefix = 'https://raw.githubusercontent.com'
// Don't run this when mouse selection changes.
if ( dataFormats().indexOf(mimeClipboardMode) != -1 )
abort()
function importCommandsFromUrl(url)
{
var m = url.match(/^https?:\\/\\/github\\.com(\\/.*)\\/blob(\\/.*\\.ini)/)
if (!m)
return;
var rawDataUrl = rawDataUrlPrefix + m[1] + m[2]
var reply = networkGet(rawDataUrl)
var commandsData = str(reply.data)
if (reply.status != 200) {
throw '\x547d\x4ee4\x83b7\x53d6\x5931\x8d25\xff01'
+ '\\nStatus code: ' + reply.status
+ '\\nError: ' + reply.error
}
if ( !commandsData.match(/^\\[Commands?\\]/) )
return;
return importCommands(commandsData);
}
var cmds = importCommandsFromUrl(str(input())) || importCommands(input())
var list = '<ul>'
for (var i in cmds) {
var cmd = cmds[i]
var cmdType =
cmd.automatic ? 'automatic' :
cmd.inMenu ? 'menu/shortcut' :
cmd.globalShortcuts ? 'global shortcut' : '<b>???</b>';
list += '<li>' + escapeHtml(cmds[i].name) + ' (' + cmdType + ')</li>'
}
list += '</ul>'
var message = '<p>\x4ece\x526a\x8d34\x677f<b>\x5bfc\x5165</b>\x547d\x4ee4\xff1f</p>' + list
notification(
'.title', '\x6709\x53ef\x7528\x7684\x43opyQ\x547d\x4ee4',
'.message', message,
'.time', timeOutSeconds*1000,
'.icon', '\xf085',
'.id', 'CopyQ_commands_in_clipboard',
'.button', '\x53d6\x6d88', '', '',
'.button', '\x5bfc\x5165', 'copyq: addCommands( importCommands(input()) )', exportCommands(cmds)
)"
Input=text/plain
Automatic=true
Icon=\xf085