The court may, by injunction, on good cause shown, restrain the party in possession from doing any act to the injury of real property:
(a) During the foreclosure of a mortgage on the property.
(b) After levy on the property and before the possession of the property is transferred pursuant to sale under the levy.
(Amended by Stats. 1982, Ch. 497, Sec. 57. Operative July 1, 1983, by Sec. 185 of Ch. 497.)