How to revert spent sugar lumps on accidentally leveling up buildings:
In my situation, I had bought one level on each building (intended, for future minigame unlocking), then I accidentally spent 9 sugar lumps during a cookie storm on level 2 mines, level 2+3 factories and level 2 wizard towers. I had 24 sugar lumps harvested all-time, and didn't want to increase that number, only to revert my misclicks.
First, open a second tab with your game in case you screw up!
Bring up the command screen (for mozilla firefox, press F12, select console and you can type in the bottom bar)
Game.Objects["Mine"].level -= 1
Game.Objects["Factory"].level -= 2
Game.Objects["Wizard tower"].level -= 1
The code above deducts levels from your buildings (-=). I imagine that += adds levels and = sets the level to a specific value, though I didn't test that.
Game.lumpsTotal = 15
The above line set my all-time sugar lumps harvested to 15 (from 24)
This gives me back 9 sugar lumps to spend, but it also increases my lumps harvested all time, which is why you need to decrease that number before you re-gain the accidentally spent lumps.
Of course, you can change the numbers and building names to apply to the specific situation for you. Hope this helps!