をいいことに means someone takes advantage of a situation to do something they shouldn't: "using X as a chance to". It goes after a noun, or after a clause turned into a noun with . The speaker disapproves, so the second half is something selfish or irresponsible.
、。
Taking advantage of the teacher being away, the students started goofing off.
、。
He takes advantage of his parents being lenient and does whatever he pleases.
、。
He's always asking her for favors, taking advantage of her kindness.
A clause needs の before を: ×先生がいないをいいことに. A な-adjective or a noun in a clause takes なの.
、。
Taking advantage of the boss being away on business, his staff left early.
The one who takes advantage is the subject of the second half. Used about yourself, it is a half-guilty confession.
、。
Since nobody was watching, I sneaked some sweets.
をいいことに or をきっかけに
marks a trigger that led to something, with no judgment. をいいことに always carries blame: the situation was used as an excuse.
、。
Studying abroad got me started cooking.
、。
With their parents away, the children took the chance to play games until late at night.
is close to をいいことに but harsher: it means preying on someone's weakness, and the victim is usually another person.