〜ついでに
While at it, taking the opportunitymachine translation
FormationNoun + の + ついでに; verb dictionary form/た-form + ついでに
A ついでに B: taking the opportunity of doing main task A, you also do side task B while you're at it: 買い物のついでに図書館に寄る (while out shopping, stop by the library). The pattern's requirement is that there MUST be a main task first — B is just something done alongside, on the way, with a little extra effort.
Connection: noun + のついでに; verb dictionary form when the main task is about to be done (駅へ行くついでに — while I'm heading to the station), た-form when the main task has been done (出張したついでに — taking advantage of that recent business trip).
ついでに can also stand alone at the start of a sentence as an adverb: ついでにこれもお願いします (while you're at it, this one too, please). In requests, this pattern noticeably softens the ask — the listener understands that what you're asking won't cost them a separate trip: 駅へ行くついでに、この手紙を出してくれませんか.
Examples
買い物のついでに、図書館に寄って本を返しました。
While out shopping, I stopped by the library to return some books.
大阪へ出張したついでに、昔の友達に会ってきました。
While on a business trip to Osaka, I met up with an old friend.
駅へ行くついでに、この手紙を出してくれませんか。
Since you're going to the station anyway, could you mail this letter for me?