We developed an optofluidic surface-enhanced Raman scattering chip capable of online fabrication, online molecular detection, and online self-cleaning. In this chip, we harnessed UV light to successfully reduce an AgNO3 solution, resulting in the formation of Ag nanoparticles on carbon fiber cloth coated with titanium dioxide (TiO2). This innovative approach enabled the online fabrication of AgNPs@TiO2-CFC SERS structures. By introducing target molecules into our optofluidic SERS chip, we achieved online molecular Raman detection. Furthermore, by leveraging the UV light-induced self-cleaning properties of TiO2, we achieved continuous online self-cleaning of the molecules. To verify the feasibility and stability of our method, we conducted multiple experiments for online detection and self-cleaning. Experimental results demonstrated impressively low detection limits of 10-8 mol/L for crystal violet and 10-9 mol/L for rhodamine 6G, with an enhancement factor as high as 1.4 × 106. Additionally, we successfully applied our method to polycyclic aromatic hydrocarbons like pyrene.