Skip to content

Commit

Permalink
Use active window for hunted (#8)
Browse files Browse the repository at this point in the history
* Pull in @chrismessina's brandfetch block

* Update info.plist
  • Loading branch information
nathangathright authored Dec 8, 2020
1 parent f8c5b33 commit 1e4ce01
Show file tree
Hide file tree
Showing 2 changed files with 254 additions and 26 deletions.
278 changes: 253 additions & 25 deletions info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,19 @@
<false/>
</dict>
</array>
<key>3CBD529B-76EA-4039-B4D3-9EF96A227CE5</key>
<array>
<dict>
<key>destinationuid</key>
<string>50CCD26F-1371-40E4-968B-5BA716862854</string>
<key>modifiers</key>
<integer>0</integer>
<key>modifiersubtext</key>
<string></string>
<key>vitoclose</key>
<false/>
</dict>
</array>
<key>44FB2A8C-0259-49E9-B5EA-0421A790CF19</key>
<array>
<dict>
Expand All @@ -45,6 +58,45 @@
</dict>
</array>
<key>4DFCC120-1209-4FD6-8198-02FCEC1F8FDA</key>
<array>
<dict>
<key>destinationuid</key>
<string>59CF48B3-C2CF-4C58-9DD3-7C97FBA6319B</string>
<key>modifiers</key>
<integer>0</integer>
<key>modifiersubtext</key>
<string></string>
<key>vitoclose</key>
<false/>
</dict>
</array>
<key>50CCD26F-1371-40E4-968B-5BA716862854</key>
<array>
<dict>
<key>destinationuid</key>
<string>639B2005-978D-4ACB-815E-824289165C13</string>
<key>modifiers</key>
<integer>0</integer>
<key>modifiersubtext</key>
<string></string>
<key>vitoclose</key>
<false/>
</dict>
</array>
<key>59CF48B3-C2CF-4C58-9DD3-7C97FBA6319B</key>
<array>
<dict>
<key>destinationuid</key>
<string>EAB1A7C0-5357-494E-88F8-4A9D329CFE69</string>
<key>modifiers</key>
<integer>0</integer>
<key>modifiersubtext</key>
<string></string>
<key>vitoclose</key>
<false/>
</dict>
</array>
<key>EAB1A7C0-5357-494E-88F8-4A9D329CFE69</key>
<array>
<dict>
<key>destinationuid</key>
Expand All @@ -68,25 +120,6 @@
<string>Product Hunt Search</string>
<key>objects</key>
<array>
<dict>
<key>config</key>
<dict>
<key>browser</key>
<string></string>
<key>spaces</key>
<string></string>
<key>url</key>
<string>{query}</string>
<key>utf8</key>
<true/>
</dict>
<key>type</key>
<string>alfred.workflow.action.openurl</string>
<key>uid</key>
<string>A394A7F5-251A-4629-908C-4552D988782B</string>
<key>version</key>
<integer>1</integer>
</dict>
<dict>
<key>config</key>
<dict>
Expand Down Expand Up @@ -136,6 +169,25 @@
<key>version</key>
<integer>3</integer>
</dict>
<dict>
<key>config</key>
<dict>
<key>browser</key>
<string></string>
<key>spaces</key>
<string></string>
<key>url</key>
<string>{query}</string>
<key>utf8</key>
<true/>
</dict>
<key>type</key>
<string>alfred.workflow.action.openurl</string>
<key>uid</key>
<string>A394A7F5-251A-4629-908C-4552D988782B</string>
<key>version</key>
<integer>1</integer>
</dict>
<dict>
<key>config</key>
<dict>
Expand Down Expand Up @@ -227,6 +279,41 @@ fi</string>
<key>version</key>
<integer>2</integer>
</dict>
<dict>
<key>config</key>
<dict>
<key>concurrently</key>
<false/>
<key>escaping</key>
<integer>68</integer>
<key>script</key>
<string>const frontmost_app_name = Application('System Events').applicationProcesses.where({ frontmost: true }).name()[0]
const frontmost_app = Application(frontmost_app_name)
const chromium_variants = ['Google Chrome', 'Chromium', 'Opera', 'Vivaldi', 'Brave Browser', 'Microsoft Edge']
const webkit_variants = ['Safari', 'Webkit']
if (chromium_variants.some(app_name =&gt; frontmost_app_name.startsWith(app_name))) {
frontmost_app.windows[0].activeTab.url().replace('http://','').replace('https://','').replace('www.','').split(/[/?#]/)[0]
} else if (webkit_variants.some(app_name =&gt; frontmost_app_name.startsWith(app_name))) {
frontmost_app.documents[0].url().replace('http://','').replace('https://','').replace('www.','').split(/[/?#]/)[0]
} else {
throw new Error('You need a supported browser as your frontmost app')
}</string>
<key>scriptargtype</key>
<integer>1</integer>
<key>scriptfile</key>
<string></string>
<key>type</key>
<integer>7</integer>
</dict>
<key>type</key>
<string>alfred.workflow.action.script</string>
<key>uid</key>
<string>59CF48B3-C2CF-4C58-9DD3-7C97FBA6319B</string>
<key>version</key>
<integer>2</integer>
</dict>
<dict>
<key>config</key>
<dict>
Expand Down Expand Up @@ -258,11 +345,11 @@ fi</string>
<key>focusedappvariablename</key>
<string></string>
<key>hotkey</key>
<integer>80</integer>
<integer>0</integer>
<key>hotmod</key>
<integer>8650752</integer>
<integer>0</integer>
<key>hotstring</key>
<string>F19</string>
<string></string>
<key>leftcursor</key>
<false/>
<key>modsmode</key>
Expand Down Expand Up @@ -326,6 +413,112 @@ fi</string>
<key>version</key>
<integer>3</integer>
</dict>
<dict>
<key>config</key>
<dict>
<key>type</key>
<integer>0</integer>
</dict>
<key>type</key>
<string>alfred.workflow.utility.transform</string>
<key>uid</key>
<string>EAB1A7C0-5357-494E-88F8-4A9D329CFE69</string>
<key>version</key>
<integer>1</integer>
</dict>
<dict>
<key>config</key>
<dict>
<key>alignment</key>
<integer>0</integer>
<key>backgroundcolor</key>
<string></string>
<key>fadespeed</key>
<integer>0</integer>
<key>fillmode</key>
<integer>0</integer>
<key>font</key>
<string></string>
<key>ignoredynamicplaceholders</key>
<false/>
<key>largetypetext</key>
<string>{query}</string>
<key>textcolor</key>
<string></string>
</dict>
<key>type</key>
<string>alfred.workflow.output.largetype</string>
<key>uid</key>
<string>639B2005-978D-4ACB-815E-824289165C13</string>
<key>version</key>
<integer>3</integer>
</dict>
<dict>
<key>config</key>
<dict>
<key>action</key>
<integer>0</integer>
<key>argument</key>
<integer>0</integer>
<key>focusedappvariable</key>
<false/>
<key>focusedappvariablename</key>
<string></string>
<key>hotkey</key>
<integer>79</integer>
<key>hotmod</key>
<integer>8650752</integer>
<key>hotstring</key>
<string>F18</string>
<key>leftcursor</key>
<false/>
<key>modsmode</key>
<integer>0</integer>
<key>relatedAppsMode</key>
<integer>0</integer>
</dict>
<key>type</key>
<string>alfred.workflow.trigger.hotkey</string>
<key>uid</key>
<string>3CBD529B-76EA-4039-B4D3-9EF96A227CE5</string>
<key>version</key>
<integer>2</integer>
</dict>
<dict>
<key>config</key>
<dict>
<key>concurrently</key>
<false/>
<key>escaping</key>
<integer>68</integer>
<key>script</key>
<string>const frontmost_app_name = Application('System Events').applicationProcesses.where({ frontmost: true }).name()[0]
const frontmost_app = Application(frontmost_app_name)
const chromium_variants = ['Google Chrome', 'Chromium', 'Opera', 'Vivaldi', 'Brave Browser', 'Microsoft Edge']
const webkit_variants = ['Safari', 'Webkit']
if (chromium_variants.some(app_name =&gt; frontmost_app_name.startsWith(app_name))) {
frontmost_app.windows[0].activeTab.url()
} else if (webkit_variants.some(app_name =&gt; frontmost_app_name.startsWith(app_name))) {
frontmost_app.documents[0].url()
} else {
throw new Error('You need a supported browser as your frontmost app')
}</string>
<key>scriptargtype</key>
<integer>1</integer>
<key>scriptfile</key>
<string></string>
<key>type</key>
<integer>7</integer>
</dict>
<key>type</key>
<string>alfred.workflow.action.script</string>
<key>uid</key>
<string>50CCD26F-1371-40E4-968B-5BA716862854</string>
<key>version</key>
<integer>2</integer>
</dict>
</array>
<key>readme</key>
<string>Search Product Hunt posts from Alfred
Expand All @@ -337,17 +530,24 @@ Locate your token by visiting https://api.producthunt.com/v2/docs and clicking
<key>1ACB45A9-A438-4781-8FD8-159A129D08ED</key>
<dict>
<key>xpos</key>
<integer>155</integer>
<integer>395</integer>
<key>ypos</key>
<integer>365</integer>
</dict>
<key>202291B7-BB85-47EE-8720-A53A39F38EF6</key>
<dict>
<key>xpos</key>
<integer>300</integer>
<integer>550</integer>
<key>ypos</key>
<integer>365</integer>
</dict>
<key>3CBD529B-76EA-4039-B4D3-9EF96A227CE5</key>
<dict>
<key>xpos</key>
<integer>15</integer>
<key>ypos</key>
<integer>590</integer>
</dict>
<key>44FB2A8C-0259-49E9-B5EA-0421A790CF19</key>
<dict>
<key>xpos</key>
Expand All @@ -362,13 +562,41 @@ Locate your token by visiting https://api.producthunt.com/v2/docs and clicking
<key>ypos</key>
<integer>365</integer>
</dict>
<key>50CCD26F-1371-40E4-968B-5BA716862854</key>
<dict>
<key>xpos</key>
<integer>160</integer>
<key>ypos</key>
<integer>590</integer>
</dict>
<key>59CF48B3-C2CF-4C58-9DD3-7C97FBA6319B</key>
<dict>
<key>xpos</key>
<integer>160</integer>
<key>ypos</key>
<integer>365</integer>
</dict>
<key>639B2005-978D-4ACB-815E-824289165C13</key>
<dict>
<key>xpos</key>
<integer>460</integer>
<key>ypos</key>
<integer>590</integer>
</dict>
<key>A394A7F5-251A-4629-908C-4552D988782B</key>
<dict>
<key>xpos</key>
<integer>150</integer>
<key>ypos</key>
<integer>10</integer>
</dict>
<key>EAB1A7C0-5357-494E-88F8-4A9D329CFE69</key>
<dict>
<key>xpos</key>
<integer>320</integer>
<key>ypos</key>
<integer>395</integer>
</dict>
<key>F1891F9A-FA8A-42C0-B58C-2F9A9059FD1C</key>
<dict>
<key>colorindex</key>
Expand All @@ -391,7 +619,7 @@ Locate your token by visiting https://api.producthunt.com/v2/docs and clicking
<string>token</string>
</array>
<key>version</key>
<string>1.1.0</string>
<string>1.2.0</string>
<key>webaddress</key>
<string>https://github.com/nathangathright/alfred-producthunt-search</string>
</dict>
Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Type the keyword `hunted` and enter a URL to check if it’s already been submit
- If the URL is found on Product Hunt, press <kbd>Return</kbd> to open the Product Hunt post.
- If the URL is not found on Product Hunt, press <kbd>Return</kbd> to open the Product Hunt submission page.

Alternatively, press <kbd>⌃</kbd> + <kbd>F19</kbd> to launch this script using the content of the clipboard as the query.
Alternatively, set up a hotkey in Alfred to pre-populate the `hunted` URL from your frontmost browser window.

## Credits
- Hat tip to [Chris Messina](https://twitter.com/chrismessina) for the nudge to create this
Expand Down

0 comments on commit 1e4ce01

Please sign in to comment.