Organic battery electrode materials represent a sustainable alternative compared to most inorganic electrodes, yet challenges persist regarding their energy density and cycling stability. In this work, a new organic electrode material is described, which is obtained via ionothermal polymerization of low-cost starting materials, melem (2,5,8-triamino-tri-s-triazine) and perylenetetracarboxylic dianhydride (PTCDA). The resulting networked polymer Melem-PDI exhibits favorable thermal and electrochemical properties, prompting investigation into its performance as a positive electrode material in rechargeable lithium and magnesium batteries. A hybrid material with carbon nanotubes (Melem-PDI-CNT) is found to exhibit-excellent cycling stability in Li-ion batteries at a current rate as high as 500 mA g-1 for 5000 cycles. While the Li-ion storage is based on a pseudocapacitive mechanism, a diffusion-controlled mechanism is observed in magnesium batteries. This work underscores that classic dyes (here: PDI) can be repurposed for energy storage, once they are integrated into suitable polymer topologies and brought into nanoscale contact with conductive materials.