Skip to content

Instantly share code, notes, and snippets.

@ahmic
Last active March 2, 2018 16:39
Show Gist options
  • Save ahmic/604d76a30aae680aeeae05616287965c to your computer and use it in GitHub Desktop.
Save ahmic/604d76a30aae680aeeae05616287965c to your computer and use it in GitHub Desktop.
Touch Bar widgets
set userName to "ahmic.jpg"
set jsonData to do shell script "curl -s 'https://www.instagram.com/" & userName & "/?__a=1'"
set AppleScript's text item delimiters to {","}
set keyValueList to (every text item in jsonData) as list
set AppleScript's text item delimiters to ""
set followersItem to item 7 of keyValueList
set followersObject to RemoveFromString("\"", followersItem)
set followersObject to RemoveFromString("{", followersObject)
set followersObject to RemoveFromString("}", followersObject)
set AppleScript's text item delimiters to {":"}
set theKeyValueFollowers to (every text item in followersObject) as list
set num to item 3 of theKeyValueFollowers
return "🕵️ " & num
-- remove character or string from given string
on RemoveFromString(CharOrString, txt)
set AppleScript's text item delimiters to CharOrString
set temp to txt's text items
set AppleScript's text item delimiters to ""
return temp as text
end RemoveFromString
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment