Has anything changed in her diet in the last 3 weeks, or has she suddenly upped the amount she eats? Are her poos hard or soft?
My 10 month old has bad nights when she wakes a lot crying because she is constipated, has lots of wind and needs to poo, then in the morning I find her standing up in the cot and she has already pooed.
It could be that if she is crying a lot it is working her tummy muscles and that coupled with the gravity from standing up is forcing it out. I seriously doubt that she is purposefully straining to push one out as soon as you leave the room, my older dd only started trying to do poos age 3, before that it was totally bodily driven.
If she eats a lot of banana, cut it out of her diet altogether to see if it makes a difference, it can easily constipate.
Also consider lactulose and up her water intake if poos are very hard to see if that helps.
If the wind is bad my dd2 hates lying down so being cuddled is more comfortable plus when you are in pain you want your mummy.
It might be nothing to do with this and just a separation anxiety phase, but if it is that then gradual withdrawal may help.
With dd1 I slowly withdrew from her sight over a two week period when teaching her to self settle, started sitting by cot reading story, to hand holding, then sitting on other side of room, sitting by door, sitting outside door where she could hear me reassuring her but not see me, to 5 min crying checks, then 10 min checks.
I know it is frustrating, but leaving her crying for 3 hours with checks might actually be playing straight into her fears of separation and be making it worse.