Last active
May 1, 2020 20:32
-
-
Save doraemoncito/c896304d343c7dc8a1f4fc380fe71b19 to your computer and use it in GitHub Desktop.
Revisions
-
doraemoncito renamed this gist
May 1, 2020 . 1 changed file with 23 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ # Save all links in the current Safari session to the macOS clipboard ## Copy all links from Safari to the clipboard as a list of URLs in JSON format @@ -27,6 +27,21 @@ Open automator and create an application script called `safe-safari-session-to-c To test this application within Automator, add the “Get Specified Finder Items” action to the beginning of your workflow without forgetting to remove or disable the action before running the workflow outside of Automator. Example output: ```console [ { "name": "Teach, Learn, and Make with Raspberry Pi – Raspberry Pi", "url": "https://www.raspberrypi.org/" }, { "name": "Home - BBC News", "url": "https://www.bbc.co.uk/news" } ] ``` ## Copy all links from Safari to the clipboard as a list of URLs in Markdown format Open automator and create an application script called `safe-safari-session-to-clipboard-markdown.app`. @@ -50,3 +65,10 @@ Open automator and create an application script called `safe-safari-session-to-c 1. Add a copy to clipboard step To test this application within Automator, add the “Get Specified Finder Items” action to the beginning of your workflow without forgetting to remove or disable the action before running the workflow outside of Automator. Example output: ```console - [Teach, Learn, and Make with Raspberry Pi – Raspberry Pi](https://www.raspberrypi.org/) - [Home - BBC News](https://www.bbc.co.uk/news) ``` -
doraemoncito created this gist
May 1, 2020 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,52 @@ # Save all links in Safari session on macOS ## Copy all links from Safari to the clipboard as a list of URLs in JSON format Open automator and create an application script called `safe-safari-session-to-clipboard-json.app`. 1. Add a JavaScript step with the following content ```javascript function run(input, parameters) { var _urlList = []; var _safari = Application('Safari'); _safari.includeStandardAdditions = true; _safari.activate(); _safari.windows().forEach(function (_window) { _window.tabs().forEach(function (_tab) { _urlList.push({"name": _tab.name(), "url": _tab.url()}); }); }); // Pretty print the stringified JSON object before returning it. For a condensed JSON string simply remove the last // two parameters from the method call below. I.e. return JSON.stringify(urlList); return JSON.stringify(_urlList, null, 2); } ``` 2. Add a copy to clipboard step To test this application within Automator, add the “Get Specified Finder Items” action to the beginning of your workflow without forgetting to remove or disable the action before running the workflow outside of Automator. ## Copy all links from Safari to the clipboard as a list of URLs in Markdown format Open automator and create an application script called `safe-safari-session-to-clipboard-markdown.app`. 1. Add a JavaScript step with the following content ```javascript function run(input, parameters) { var _urlList = []; var _safari = Application('Safari'); _safari.includeStandardAdditions = true; _safari.activate(); _safari.windows().forEach(function (_window) { _window.tabs().forEach(function (_tab) { _urlList.push("- [" + _tab.name() + "](" + _tab.url() + ")"); }); }); return _urlList.join("\n"); } ``` 1. Add a copy to clipboard step To test this application within Automator, add the “Get Specified Finder Items” action to the beginning of your workflow without forgetting to remove or disable the action before running the workflow outside of Automator.