-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScript.js
More file actions
23 lines (19 loc) · 750 Bytes
/
Copy pathScript.js
File metadata and controls
23 lines (19 loc) · 750 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/*
Input: URL of a tweet you want to share.
Output: Embed code for a blog.
Usig twitter API: https://developer.twitter.com/en/docs/twitter-for-websites/embedded-tweets/overview
*/
let inputUrl = args.urls[0]
let requestUrl = "https://publish.twitter.com/oembed?url=" + encodeURIComponent(inputUrl)
let publishRequest = new Request(requestUrl)
let body = await publishRequest.loadString()
let obj = JSON.parse(body)
let embedCode = obj.html
Pasteboard.copyString(embedCode)
let notify = new Notification()
notify.title = "Embed code copied!"
// notify.body causes notification to fail for some reason
let fireDate = new Date()
fireDate.setMilliseconds(fireDate.getMilliseconds() + 500)
notify.setTriggerDate(fireDate)
notify.schedule()