Hi, I would like to create a macro that will copy all of the Name and URL of the frontmost Arc Browser window, so I can paste the results in Apple Notes or another software
I was able to write this script to get the name and url of the active tab of the Arc front window
tell application "Arc"
set theTitle to title of active tab of front window
set theUrl to URL of active tab of front window
set the clipboard to "[" & theTitle & "]
(" & theUrl & ")"
end tell
Unfortunately, with my really limited Applescript knowledge I can't go any further.
How can I modify this script to get the names and url of all the tabs of the Arc frontmost window, skipping the pinned tabs?
Thanks a lot @ComplexPoint !
Your last example is exactly what I need, I just wold like to divide the Page Title and the Url with a line break to have better clarity when I paste the text.
PS to restrict your harvest to unpinned tabs on the front window you would need a .where or .whose clause:
Expand disclosure triangle to view JS source
(() => {
"use strict";
const main = () => {
const
frontWindowUnpinnedTabs = Application("Arc")
.windows.at(0)
.tabs.where({location: "unpinned"});
return zipWith(
title => url => `${title}\t${url}`
)(
frontWindowUnpinnedTabs.title()
)(
frontWindowUnpinnedTabs.url()
)
.join("\n");
};
// --------------------- GENERIC ---------------------
// zipWith :: (a -> a -> b) -> [a] -> [b]
const zipWith = f =>
// A list with the length of the shorter of
// xs and ys, defined by zipping with a
// custom function, rather than with the
// default tuple constructor.
xs => ys => xs.slice(
0, Math.min(xs.length, ys.length)
)
.map((x, i) => f(x)(ys[i]));
return main();
})();
Thanks a lot @ComplexPoint with your help I was able to get two scripts, one copies all the tabs and the other only the unpinned ones and there's a carriage return between tab name and URL
Hey there,
I am trying to replicate this as this would be really useful for me but I am not sure how to choose JavaScript for the macro.
(Sorry real newbie here)
Welcome to the forum. This is a very great and helpful and friendly Community.
In your case you chose the wrong Action. Just switch to the Execute JavaScript for Automation Action. If the script doesn’t use the modern syntax you’re good to go but if not there is a setting for it in the action on the left side of the Textbox for the Script (KM 11.0+)