Make constant thikr and remember Allah. A good way is to bring Allah to mind everytime you have a bad thought. Allah will correct your perspective inshallah. Another way is to extend your right hand index like salaah (When you say Ash hadu Allah illah haillah, this is when one extends ones index finger to declare that Allah is one inshallah)
Here's also a good duaa from the Quran.
Rabbi inni maghlubun fantassir (O Allah! I am overcome, help me. (Surat al- Qamar, 10)
Repeat the above duaa whenever you are being overwhelmed with waswasa inshallah.
Inshallah I hope I have helped you
Salaam