Created
January 27, 2024 12:07
-
-
Save dsumin/8ecc853d5ffa450988783079a34489a3 to your computer and use it in GitHub Desktop.
Raycast script that copies link to the current node using "tana://" protocol
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 osascript -l JavaScript | |
// Dependency: This script requires Tana "Copy link" (permalink) hotkey to be set to opt+cmd-ctrl+p | |
// Required parameters: | |
// @raycast.schemaVersion 1 | |
// @raycast.title Copy link to current node in Tana | |
// @raycast.mode silent | |
// Optional parameters: | |
// @raycast.icon 🔗 | |
// Documentation: | |
// @raycast.description Copy link to the current node using "tana://" protocol | |
// @raycast.author Dmitry Sumin | |
// @raycast.authorURL https://github.com/dsumin | |
var app = Application.currentApplication(); | |
app.includeStandardAdditions = true; | |
delay(0.3); | |
// playback keystroke "p" using {control down, option down, command down} | |
events = Application("System Events"); | |
events.keyCode(35, {using: ['command down', 'option down', 'control down']}); | |
delay(0.3); | |
// Replace https:// with tana:// | |
var clipboardContent = app.theClipboard(); | |
var newContent = clipboardContent.replace('https://app.tana.inc?nodeid=', 'tana://node/'); | |
app.setTheClipboardTo(newContent); | |
// Log the clipboard content | |
console.log(newContent); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment