safari = Application("Safari");
for (var i = 1; i < safari.windows.length; i++) {
var win = safari.windows[i];
if (win.miniaturized() === false) win.miniaturized = true;
}
Application("Google Chrome Canary").windows[0].activeTab.execute({
javascript: "window.getSelection().toString()",
});
(() => {
"use strict";
const main = () => {
const tp3Context = (editor, options) => {
const main = () =>
unlines(
concatMap((x) => {
const txt = x[options.textProperty];
return options.skipBlankLines && 0 === txt.length ? [] : [txt];
}, editor.selection.selectedItems)
);
const concatMap = (f, xs) => xs.reduce((a, x) => a.concat(f(x)), []);
const unlines = (xs) => xs.join("\n");
return main();
};
const ds = Application("TaskPaper").documents,
lrResult = bindLR(
ds.length > 0 ? Right(ds.at(0)) : Left("No TaskPaper documents open"),
(d) =>
Right(
d.evaluate({
script: tp3Context.toString(),
withOptions: {
skipBlankLines: true,
textProperty: "bodyContentString",
},
})
)
);
return lrResult.Left || lrResult.Right;
};
const Left = (x) => ({
type: "Either",
Left: x,
});
const Right = (x) => ({
type: "Either",
Right: x,
});
const bindLR = (m, mf) => (undefined !== m.Left ? m : mf(m.Right));
return main();
})();