-
Notifications
You must be signed in to change notification settings - Fork 1
/
.finicky.js
144 lines (142 loc) · 5.1 KB
/
.finicky.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
module.exports = {
defaultBrowser: "Browserosaurus",
// https://github.com/johnste/finicky/wiki/Configuration#general-options
options: {
hideIcon: true,
},
rewrite: [
{
match: () => true, // Execute rewrite on all incoming urls to make this example easier to understand
url({ url }) {
const removeKeysStartingWith = ["utm_", "uta_"]; // Remove all query parameters beginning with these strings
const removeKeys = ["fblid", "gclid"]; // Remove all query parameters matching these keys
const search = url.search
.split("&")
.map((parameter) => parameter.split("="))
.filter(
([key]) =>
!removeKeysStartingWith.some((startingWith) =>
key.startsWith(startingWith)
)
)
.filter(
([key]) =>
!removeKeys.some((removeKey) => key === removeKey)
);
return {
...url,
search: search
.map((parameter) => parameter.join("="))
.join("&"),
};
},
},
{
// Replace domain of urls to amazon.com with smile.amazon.com
match: "amazon.com/*",
url: {
host: "smile.amazon.com",
},
},
],
handlers: [
{
// Redirect all web links
// from: https://app.slack.com/client/<team id>/<channel>
// to: slack://channel?team=<team-id>&id=<channel-id>
//
// Redirect all deep linked messages
// from: https://<subdomain>.slack.com/archives/<channel-id>/p<16-digit-timestamp>
// to: slack://channel?team=<team-id>&id=<channel-id>&message=<10-digit-6-decimal-timestamp>
browser: "/Applications/Slack.app",
match: [
'*.slack.com/client/*',
'*.slack.com/archives/*'
],
url({ url }) {
const parts = url.pathname.split('/')
// Return input URL if no expected path is found
if (parts.length < 2) return url
let team
switch (parts[1]) {
// For direct web links
case 'client':
team = parts[2]
parts.splice(2, 1) // Remove team identifier to match archives format
break
// For deep links
case 'archives':
const org = url.host.split('.')[0]
switch (org) {
case 'taxify':
// Starts with a T and can be found in the web app URL for any channel in your org
team = 'T02SA4XL8'
break
default:
// Return input URL if no team lookup available
return url
}
}
search = `team=${team}`
let channel = parts[2]
if (parts.length === 3) {
// If this is a link to a channel/user
search = `${search}&id=${channel}`
// If this is a link to a message
} else if (parts.length === 4) {
const message = parts[3].slice(1, 11) + '.' + parts[3].slice(11)
search = `${search}&channel=${channel}&message=${message}`
}
return {
protocol: "slack",
username: "",
password: "",
host: "channel",
port: null,
pathname: "",
search: search,
hash: ""
}
}
},
// https://github.com/johnste/finicky/wiki/Configuration-ideas#open-spotify-links-in-spotify-app
{
match: "open.spotify.com/*",
browser: "Spotify",
},
{
// Open Zoom links in Zoom app
match: [
"zoom.us/*",
finicky.matchDomains(/.*\zoom.us/),
/zoom.us\/j\//,
],
browser: "us.zoom.xos",
},
{
match: "https://www.figma.com/file/*",
browser: "Figma",
},
{
// Open apple.com and example.org urls in Safari
match: finicky.matchHostnames([
"localhost",
"github.com",
"taxify.atlassian.net",
"bolt.zoom.us",
"small-improvements.com",
"taxify.slack.com",
"docs.google.com",
"app2.greenhouse.io",
]),
browser: "Brave Browser",
},
{
// Open any link clicked in Slack in Safari
match: ({ sourceBundleIdentifier }) =>
sourceBundleIdentifier === "com.tinyspeck.slackmacgap" ||
sourceBundleIdentifier === "com.googlecode.iterm2",
browser: "Brave Browser",
},
],
};