On hearing the news, she rejoiced as though out of her mind with joy.

Literal

She [topic-は] that news [object-を] hearing [then-て], spirit [also-も] go-mad [as-if-about-to-んばかりに] rejoiced.

気も狂わんばかりに ('almost as if going mad') uses the same ~んばかりに structure ('as if on the verge of') paired with 気が狂う ('go mad / lose one's mind'). The も in place of expected が adds an 'even' nuance: 'her very mind was practically being driven mad.' The whole phrase 気も狂わんばかりに喜ぶ is a literary intensifier for joy so extreme it borders on madness — the joyful counterpart to 胸が張り裂けんばかりに泣く. Both structures sit in dramatic, fiction-style narration.