Last active
September 15, 2023 16:22
-
-
Save SKaplanOfficial/d0635c9667703de8dd0db43cbbd857b3 to your computer and use it in GitHub Desktop.
PyXA script to save the current Safari tab's URL to a "Saved URLs" note
This file contains 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 characters
#!/usr/bin/env python | |
# Test with PyXA 0.1.0 | |
import PyXA | |
safari = PyXA.Application("Safari") | |
notes = PyXA.Application("Notes") | |
# Get info for current Safari tab | |
current_tab = safari.front_window.current_tab | |
current_name = "\n" + current_tab.name | |
current_url = "\n<a href=" + str(current_tab.url) + ">" + str(current_tab.url) + "</a>" | |
note = notes.notes().by_name("Saved URLs") | |
if note is None: | |
# Create new note | |
notes.new_note("Saved URLs", current_name + current_url) | |
else: | |
# Append to existing note | |
note.set_property("body", note.body + "<br/>" + current_name + "<br/>" + current_url) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment