I'm using BetterTouchTool to customise touchbar on MacBook Pro. So far I've used script bellow to display list of tabs opened in Chrome. I would like to display favicon next to page name.
if application "Google Chrome" is running then
tell application "Google Chrome"
try
set windowCount to number of windows
repeat with x from 1 to windowCount
set maxSize to 15
set tabcount to number of tabs in window x
repeat with y from 1 to tabcount
set tabName to title of tab 1 of window x
if length of tabName is greater than maxSize then
set tabName to text 1 thru (maxSize - 3) of tabName & "..."
end if
return tabName
end repeat
end repeat
on error
return ""
end try
end tell
else
return ""
end if
Edit 1 (new script after the answer)
if application "Google Chrome" is running then
tell application "Google Chrome"
set windowCount to number of windows
repeat with x from 1 to windowCount
set maxSize to 15
set tabcount to number of tabs in window x
repeat with y from 1 to tabcount
set tabName to title of tab 1 of window x
if length of tabName is greater than maxSize then
set tabName to text 1 thru (maxSize - 3) of tabName & "..."
end if
set tabIcon to execute of tab 1 of window x javascript ¬
"document.head.querySelector('link[rel~=icon]').href;"
return "{\"text\":\"" & (tabName) & "\",
\"icon_data\": \"base64_icon_data\",
\"icon_path\":\"" & (tabIcon) & "\",
\"background_color\": \"255,85,100,255\",
\"font_color\": \"100,200,100,255\",
\"font_size\": 10}"
end repeat
end repeat
end tell
else
return ""
end if
It's possible that I'm missing something very obvious since I'm new to Applescript.