-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOpenFavourite.js
50 lines (43 loc) · 986 Bytes
/
OpenFavourite.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
//
// Copyright (c) 2016 Dean Jackson <deanishe@deanishe.net>
//
// MIT Licence. See http://opensource.org/licenses/MIT
//
// Created on 2016-11-06
//
ObjC.import('stdlib')
var Transmit = Application('Transmit')
Transmit.includeStandardAdditions = true
// Return favourite for UID or null
function findFave(uid) {
var faves = Transmit.favorites.whose({
identifier: uid
})
if (faves.length == 0) {
return null
}
return faves[0]
}
// Open favourite with UID
function openFave(uid) {
var doc = null,
fav = findFave(uid)
if (fav === null) {
console.log('Favourite not found: ' + uid)
return false
}
doc = Transmit.Document().make()
// Activate transmit if necessary
if (!Transmit.frontmost()) {
Transmit.activate()
}
// Open fave
doc.currentTab.connect({to:fav})
return true
}
function run(argv) {
var uid = argv[0]
if (!openFave(uid)) {
$.exit(1)
}
}