Get a piece of Romex the same gauge as what's in there, a blank switch cover, some wire nuts, and a new box. In the old switch box, wirenut the black wire of the old switch to the black of your new Romex, white to white, and ground to ground. Recolor the white on both ends to black with tape or a sharpie. Mount your new box, wire the black, recolored white, and ground of your Romex to each leg/ground screw of the switch.