The effects of energy injection into the intergalactic and intracluster media