Fully aromatic, organic polymers have the advantage of being composed from light, abundant elements, and are hailed as candidates in electronic and optical devices “beyond silicon”, yet, applications that make use of their π-conjugated backbone and optical bandgap are lacking outside of heterogeneous catalysis. Herein, we use a series of sulfur- and nitrogen-containing porous polymers (SNPs) as real-time optical and electronic sensors reversibly triggered and re-set by acid and ammonia vapors. Our SNPs incorporate donor-acceptor and donor-donor motifs in extended networks and enable us to study the changes in bulk conductivity, optical bandgap, and fluorescence life-times as a function of π-electron de-/localization in the pristine and protonated states. Interestingly, we find that protonated donor-acceptor polymers show a decrease of the optical bandgap by 0.42 eV to 0.76 eV and longer fluorescence life-times. In contrast, protonation of a donor-donor polymer does not affect its bandgap; however, it leads to an increase of electrical conductivity by up to 25-fold and shorter fluorescence life-times. The design strategies highlighted in this study open new avenues towards useful chemical switches and sensors based on modular purely organic materials.