Skip to content

Commit 1ba01db

Browse files
authored
Merge pull request muan#73 from muan/safari
Add a basic Safari port without build
2 parents 2441ea1 + 8331eb2 commit 1ba01db

5 files changed

Lines changed: 409 additions & 31 deletions

File tree

README.md

Lines changed: 39 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,64 @@
11
# Helper for GitHub notifications in Gmail
22

3-
This is a **Chrome extension**~~/Firefox addon~~[(out of date)](https://github.com/muan/github-gmail/issues/70) that allows you to open threads in GitHub notification emails with a shortcut. :sparkles:
3+
This is a Chrome, ~~Firefox addon~~[(broken)](https://github.com/muan/github-gmail/issues/70), Safari Extension that allows you to open threads in GitHub notification emails with a shortcut. :sparkles:
44

55
## Features
66

7-
#### Mail View Shortcut
7+
### Mail View Shortcut
8+
9+
Open your GitHub notifications in mail view:
810

9-
Open your GitHub notifications using a shortcut (default to `shift + g`, or `shift + b` to open in the background in Chrome), or this button in mail view:
11+
- Chrome/Firefox: <kbd>shift</kbd> + <kbd>g</kbd>, <kbd>shift</kbd> + <kbd>b</kbd> in the background
12+
- Safari: <kbd>ctrl</kbd> + <kbd>g</kbd>, <kbd>ctrl</kbd> + <kbd>b</kbd> in the background
1013

1114
![Mail view button](https://user-images.githubusercontent.com/1153134/42123231-69153916-7c1c-11e8-8bf5-1d8fa2510b63.png)
1215

13-
#### List View Shortcut
16+
### List View Shortcut
1417

15-
The shortcut is `ctrl + return(enter)` (currently non-customizable). It will trigger one the action button when an email is selected using key navigation (when the blue bar appears):
18+
<kbd>ctrl</kbd> + <kbd>return</kbd> to trigger one the action button when an email is selected using gmail key navigation (when the blue bar appears):
1619

1720
![action button in list view](https://user-images.githubusercontent.com/1153134/42123260-fa87c648-7c1c-11e8-8d64-9ddd8899e594.png)
1821

19-
#### Mute Thread
20-
If you no longer want to receive notifications for a certain thread on GitHub, click the `Mute thread` button or using a shortcut `shift + h`, it will open a background window to load the mute thread request, and close itself when done.
22+
### Mute Thread
23+
24+
Mute thread in mail view. It will open a background window to load the mute thread URL, and close itself when done. This only works if you have an active GitHub session.
25+
26+
- Chrome/Firefox: <kbd>shift</kbd> + <kbd>h</kbd>
27+
- Safari: <kbd>ctrl</kbd> + <kbd>h</kbd>
2128

2229
![Mute thread button](https://user-images.githubusercontent.com/1153134/42123234-7c6d271c-7c1c-11e8-9b13-3cd0cbea4eab.png)
2330

2431
## Installation
2532

26-
### Chrome
27-
#### The Easy Way
33+
### The easy
2834

29-
[Install the extension via Chrome webstore](https://chrome.google.com/webstore/detail/github-notification-helpe/gmhijkhbpihfmkmhmcfebmlkaekgmaje).
35+
Chrome: [Install the extension via Chrome webstore](https://chrome.google.com/webstore/detail/github-notification-helpe/gmhijkhbpihfmkmhmcfebmlkaekgmaje)<br>
36+
~~Firefox: [Install the addon via Firefox addons gallery](https://addons.mozilla.org/en-US/firefox/addon/github-for-gmail/)~~<br>
37+
Safari: N/A I have not signed up for Apple Developer Program
3038

31-
#### The Mu-An-might-steal-all-my-data-so-I-want-to-manually-load-it Way (for Chrome)
39+
### The manual way
3240

33-
1. Go to [Releases](https://github.com/muan/github-gmail/releases) and download the latest version.
34-
2. Unzip the folder wherever you'd like.
35-
3. Read Mu-An's code, making sure there is no data stealing.
36-
4. Go to Chrome extensions page (`chrome://extensions/`) and load the folder as an **Unpacked extension**.
41+
#### Chrome
3742

38-
As:
43+
1. Go to [Releases](https://github.com/muan/github-gmail/releases) and download the latest version and unzip it.
44+
2. Go to Chrome extensions page (`chrome://extensions/`) and load the folder as an **Unpacked extension**.
3945

40-
![load unpacked](https://user-images.githubusercontent.com/1153134/42123174-45ecb064-7c1b-11e8-81fd-9722627af801.png)
46+
#### Firefox
4147

42-
### Firefox
48+
https://github.com/muan/github-gmail/issues/70
4349

44-
~~[Install the addon via Firefox addons gallery](https://addons.mozilla.org/en-US/firefox/addon/github-for-gmail/)~~
50+
#### Safari
4551

46-
Firefox addon is out of date, see https://github.com/muan/github-gmail/issues/70.
52+
1. Go to [Releases](https://github.com/muan/github-gmail/releases) and download the latest version and unzip it.
53+
2. `Preferences` > `Advanced` > `Show Develop menu in menu bar`
54+
3. `Develop` > `Show Extension Builder` > `+` > `Add Extension` > Choose the folder > `Run`
4755

48-
## Options and preferences
49-
50-
There are 3 preference settings:
56+
## Settings
5157

5258
1. Custom domains
53-
2. Mail view shortcut
54-
3. List view regular expression
55-
56-
**Attention** After updating a setting, please refresh both the extensions page and the Gmail page.
59+
2. Mail view: open thread shortcut
60+
3. Mail view: open thread in background shortcut
61+
4. Mail view: mute thread shortcut
5762

5863
#### Custom Domains (for GitHub Enterprise)
5964

@@ -77,13 +82,16 @@ Customize the keyboard shortcut that triggers the `View on GitHub` button. Chang
7782

7883
![image](https://user-images.githubusercontent.com/1153134/42123283-445a047a-7c1d-11e8-8ca7-44912c4c85d4.png)
7984

80-
## Code
85+
## Development
86+
87+
Load the extension manually and modify the code accordingly in these places:
8188

8289
Chrome: `chrome/src/inject/inject.js`.<br>
83-
Firefox: `firefox/data/index.js`.
90+
Firefox: `firefox/data/index.js`.<br>
91+
Safari: `safari/github-gmail-safariextension/main.js`
8492

8593
## The End
8694

87-
**Love :heart: it?** [Tell me](https://twitter.com/muanchiou)!
95+
**Love it?** [Tell me](https://twitter.com/muanchiou)!
8896

89-
**Found a :bug: bug?** [Open an issue](https://github.com/muan/github-gmail/issues/new) with some [emojis](http://emoji.muan.co). Issues without emojis are not valid. :trollface:
97+
**Found a bug?** [Open an issue](https://github.com/muan/github-gmail/issues/new).
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>Author</key>
6+
<string>Mu-An Chiou</string>
7+
<key>Builder Version</key>
8+
<string>14606.3.4</string>
9+
<key>CFBundleDisplayName</key>
10+
<string>github-gmail</string>
11+
<key>CFBundleIdentifier</key>
12+
<string>muan.github-gmail</string>
13+
<key>CFBundleInfoDictionaryVersion</key>
14+
<string>6.0</string>
15+
<key>CFBundleShortVersionString</key>
16+
<string>1.0</string>
17+
<key>CFBundleVersion</key>
18+
<string>1</string>
19+
<key>Chrome</key>
20+
<dict>
21+
<key>Global Page</key>
22+
<string>global.html</string>
23+
</dict>
24+
<key>Content</key>
25+
<dict>
26+
<key>Scripts</key>
27+
<dict>
28+
<key>Start</key>
29+
<array>
30+
<string>main.js</string>
31+
</array>
32+
</dict>
33+
</dict>
34+
<key>Description</key>
35+
<string>Open GitHub notifications with shortcuts in Gmail.</string>
36+
<key>ExtensionInfoDictionaryVersion</key>
37+
<string>1.0</string>
38+
<key>Permissions</key>
39+
<dict>
40+
<key>Website Access</key>
41+
<dict>
42+
<key>Allowed Domains</key>
43+
<array>
44+
<string>mail.google.com</string>
45+
</array>
46+
<key>Include Secure Pages</key>
47+
<true/>
48+
<key>Level</key>
49+
<string>Some</string>
50+
</dict>
51+
</dict>
52+
<key>Website</key>
53+
<string>https://github.com/muan/github-gmail</string>
54+
</dict>
55+
</plist>
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<array>
5+
<dict>
6+
<key>DefaultValue</key>
7+
<string>ctrl + 71</string>
8+
<key>Key</key>
9+
<string>shortcut</string>
10+
<key>Title</key>
11+
<string>shortcut</string>
12+
<key>Type</key>
13+
<string>TextField</string>
14+
</dict>
15+
<dict>
16+
<key>DefaultValue</key>
17+
<string>ctrl + 66</string>
18+
<key>Key</key>
19+
<string>backgroundShortcut</string>
20+
<key>Password</key>
21+
<false/>
22+
<key>Title</key>
23+
<string>backgroundShortcut</string>
24+
<key>Type</key>
25+
<string>TextField</string>
26+
</dict>
27+
<dict>
28+
<key>DefaultValue</key>
29+
<string>ctrl + 72</string>
30+
<key>Key</key>
31+
<string>muteShortcut</string>
32+
<key>Title</key>
33+
<string>muteShortcut</string>
34+
<key>Type</key>
35+
<string>TextField</string>
36+
</dict>
37+
<dict>
38+
<key>Key</key>
39+
<string>domains</string>
40+
<key>Title</key>
41+
<string>domains</string>
42+
<key>Type</key>
43+
<string>TextField</string>
44+
</dict>
45+
</array>
46+
</plist>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<script type="text/javascript">
2+
safari.application.activeBrowserWindow.addEventListener('message', function(event) {
3+
if (event.name === 'get-settings') {
4+
const {shortcut, backgroundShortcut, muteShortcut, domains} = safari.extension.settings
5+
event.target.page.dispatchMessage('settings', {
6+
shortcut, backgroundShortcut, muteShortcut, domains
7+
})
8+
} else if (event.name === 'new-tab') {
9+
const newTab = safari.application.activeBrowserWindow.openTab(event.message.active ? 'foreground' : 'background')
10+
const activePage = event.target.page
11+
12+
if (event.message.mute) {
13+
newTab.addEventListener('navigate', function() {
14+
newTab.close()
15+
activePage.dispatchMessage('muted', {
16+
url: event.message.url
17+
})
18+
})
19+
}
20+
21+
newTab.url = event.message.url
22+
}
23+
})
24+
</script>

0 commit comments

Comments
 (0)