Skip to content

Commit

Permalink
add support for Firefox Developer Edition. add UPDATE_FREQUENCY varia…
Browse files Browse the repository at this point in the history
…ble.
  • Loading branch information
pnlng committed Feb 29, 2020
1 parent 61f37e4 commit 01735ba
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 11 deletions.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ An optional [PopClip](https://pilotmoon.com/popclip/) extension is also availabl
- [Copying URLs](#copying-urls)
- [Adding to OmniFocus](#adding-to-omnifocus)
- [Browser Specific](#browser-specific)
- [Browser Support](#browser-support)
- [Known Issues](#known-issues)
- [Acknowledgements](#acknowledgements)
</details>

Expand Down Expand Up @@ -133,6 +135,19 @@ There are a few browser specific tools that can send the frontmost web page and
- [Script for Safari](https://github.com/jessesquires/safari-tabs-to-omnifocus)
- [Chrome extension](https://chrome.google.com/webstore/detail/send-to-omnifocus/ohdhaodomnlifoigpfcbjpcegdbefnen)

## Browser Support

- Firefox (including Firefox Developer Edition)
- Chrome
- Safari
- Brave
- Opera

## Known Issues

- If both Firefox and Firefox Developer Edition are running, the workflow may not get the correct title.
- Both processes are named 'firefox', and AppleScript cannot distinguish the two by name.

## Acknowledgements

This workflow is inspired by these articles and projects.
Expand Down
Binary file modified URL Actions.alfredworkflow
Binary file not shown.
22 changes: 16 additions & 6 deletions actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,31 @@ def asquote(astr):
return '"{}"'.format(astr)


def get_title():
# only get the window title if frontmost app is in the list of browsers specified
def get_app_name():
ascript = '''
const frontmost_app_name = Application('System Events').applicationProcesses.where({ frontmost: true }).name()[0]
const frontmost_app = Application(frontmost_app_name)
frontmost_app.windows[0].name()'''
Application('System Events').applicationProcesses.where(
{ frontmost: true }).name()[0]
'''
return asrun(ascript).strip()


def get_title(app_name):
ascript = '''
const frontmost_app = Application('{}')
frontmost_app.windows[0].name() '''.format(app_name)
title = asrun(ascript).strip()
if app_name == 'firefox':
return re.sub(' - Firefox Developer Edition$', '', title)
return title


def clean_url(url):
return re.sub(r'(^.*/(?:dp|gp/product)/([^/?]+)).*$', r'\1', url)


def main(wf):
title = wf.decode(get_title())
app_name = get_app_name()
title = wf.decode(get_title(app_name))
url = wf.decode(wf.args[0]) if len(wf.args) else None
if os.environ.get('CLEAN_AMAZON') == 'true':
url = clean_url(url)
Expand Down
15 changes: 10 additions & 5 deletions info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -414,10 +414,13 @@ python actions.py $query</string>
Variables:
- `CLEAN_AMAZON` - Default `true`
- The workflow removes tracking tokens from Amazon URLs if this variable is set to `true`.
- To disable the feature, set the variable to `false`.
- `CUSTOM_ACTIONS` - Default unspecified.
- You can supply custom actions that override the default actions. See GitHub repo for details.
- The workflow removes tracking tokens from Amazon URLs if this variable is set to `true`.
- To disable the feature, set the variable to `false`.
- `UPDATE_FREQUENCY` - Default 7
- Set once how many days the workflow should check for updates
- Updates done through [OneUpdater](https://github.com/vitorgalvao/alfred-workflows/tree/master/OneUpdater)
- `CUSTOM_ACTIONS` - Default unspecified.
- You can supply custom actions that override the default actions.
GitHub repo: https://github.com/pnlng/url-actions</string>
<key>uidata</key>
Expand Down Expand Up @@ -498,11 +501,13 @@ GitHub repo: https://github.com/pnlng/url-actions</string>
<dict>
<key>CLEAN_AMAZON</key>
<string>true</string>
<key>UPDATE_FREQUENCY</key>
<string>7</string>
</dict>
<key>variablesdontexport</key>
<array/>
<key>version</key>
<string>1.1.3</string>
<string>1.1.4</string>
<key>webaddress</key>
<string>https://github.com/pnlng/alfred-url-actions</string>
</dict>
Expand Down

0 comments on commit 01735ba

Please sign in to comment.