Function-switchable metal/semiconductor junction enables efficient photocatalytic overall water splitting with selective water oxidation products.