Last active
November 28, 2024 13:40
-
-
Save ryngonzalez/6181d2263eacfc2027c0665e2cae697e to your computer and use it in GitHub Desktop.
A Scriptable widget setup to easily copy and paste links!
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
// Variables used by Scriptable. | |
// These must be at the very top of the file. Do not edit. | |
// icon-color: light-gray; icon-glyph: link; | |
// share-sheet-inputs: url; | |
// Set up constants, pull link from Widget parameter | |
const link = args.widgetParameter | |
const title = "Copied!" | |
const widgetText = "Copy Link" | |
// Create and style widget | |
const widget = new ListWidget() | |
widget.spacing = 2 | |
// Add Image in widget | |
const symbol = SFSymbol.named("link") | |
const image = widget.addImage(symbol.image) | |
image.imageSize = new Size(24, 24) | |
image.tintColor = new Color("#fff", 0.3) | |
// Add Text in widget | |
const text1 = widget.addText(widgetText) | |
text1.font = Font.blackRoundedSystemFont(24) | |
const text2 = widget.addText(link) | |
text2.font = Font.mediumMonospacedSystemFont(10) | |
// Copy link to pasteboard | |
Pasteboard.copy(link) | |
// Setup widget | |
if(config.runsInWidget) { | |
widget.presentSmall() | |
Script.setWidget(widget) | |
} | |
// When back in app, run a notification toast to confirm link is copied | |
if (config.runsInApp) { | |
const notification = new Notification() | |
notification.title = title | |
notification.body = link | |
notification.sound = "complete" | |
notification.schedule() | |
} | |
Script.complete() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment