Quickstart: Star/Unstar selected tasks
If your almost perfect task system needs something to star things up, the script below might be exactly what you're looking for.
How it works
- The script gets selected tasks.
-
If none of the tasks start with ⭐️, it adds ⭐️ to the beginning of each selected task.
⭐️ Pick up the milk at the corner shop along the Milky Way - Otherwise, it removes ⭐️ from the tasks.
Set it up
- Open the web app or desktop app.
- Click the MilkScript button at the top right, then click New...
- Copy the code below and paste it into the script editor.
const star = '⭐️';
const selectedTasks = rtm.getSelectedTasks();
if (selectedTasks.length === 0) {
throw new Error("There are no selected tasks.");
}
const isStarred = selectedTasks.some(task => task.getName().startsWith(star));
selectedTasks.forEach(task => {
if (isStarred) {
task.setName(task.getName().replace(new RegExp(`^${star}`), '').trim());
} else {
task.setName(`${star} ${task.getName()}`);
}
});
- At the top left, click Untitled script.
- Enter a name for your script (e.g. Star/Unstar selected tasks), then close the script editor.
Try it out
- Select any number of tasks.
- Click the MilkScript button at the top right.
- Click the recently created script, then click Yes, run script.
- When the script execution completes, the tasks will become starred.
- Optionally, to collect tasks with a star, create Starred Smart List with the following criteria: name:⭐️