Last active
March 4, 2022 10:35
-
-
Save chrisndeca/fab1b3c2bdcf212f02af1e2c24ec9c2b to your computer and use it in GitHub Desktop.
eBay Auction to Google Calendar Scriptable Share Sheet script
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 characters
//Must be used through the Scriptable Share Sheet Action from the eBay App. | |
function splitFunc(aString,aDelim,thePos) { | |
let newArray = aString.split(aDelim) | |
return newArray[thePos] | |
} | |
let argsURL = args.urls[0]; | |
let shortURL = splitFunc(argsURL,"?",0); | |
let wv = new WebView(); | |
await wv.loadURL(shortURL); | |
let html = await wv.getHTML(); | |
let secondHalfhtml = splitFunc(html,"<title>", 1); | |
let auctionName = splitFunc(secondHalfhtml,"|",0); | |
let priceParse1 = splitFunc(html,"US $", 1); | |
let thePrice = splitFunc(priceParse1, "<",0); | |
let timeParse = splitFunc(html,"timems=\"", 1); | |
let epochTime = splitFunc(timeParse, "\">", 0); | |
let theDate = new Date(epochTime * 1); | |
let ye = new Intl.DateTimeFormat('en', {year: 'numeric'}).format(theDate); | |
let mo = new Intl.DateTimeFormat('en', {month: '2-digit'}).format(theDate); | |
let da = new Intl.DateTimeFormat('en', {day: '2-digit'}).format(theDate); | |
let ho = new Intl.DateTimeFormat('en', {hour: 'numeric', hour12: false}).format(theDate); | |
let mi = new Intl.DateTimeFormat('en', {minute: 'numeric'}).format(theDate); | |
let se = new Intl.DateTimeFormat('en', {second: 'numeric'}).format(theDate); | |
let encodedAuctionname = encodeURIComponent(auctionName); | |
let calendarURLparts = ["http://www.google.com/calendar/render?action=TEMPLATE&text=", encodedAuctionname, "&dates=", ye, mo, da, "T", ho, mi, se, "Z/", ye, mo, da, "T", ho, mi, se, "Z&details=",shortURL, "%0A", thePrice, "&location=", shortURL, "&=true&sprop=&sprop=name:"]; | |
let calendarURL = calendarURLparts.join(""); | |
await wv.loadURL(calendarURL); | |
await wv.present(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I stumbled upon this trying to find a way to easily add auction end times to google calendar - I vaguely remember doing this in the past, but cannot remember how or find an easy way (e.g. Chrome extension).
I am not very familiar with programming/using java script - do you know if is there a way I can using this on a windows PC?
Thanks.