I have a shared hosting and some wordpress websites on that. Recently sometimes when I visit my websites, popup opens. So I opened template directory of one wordpress website in
Apparently your site has been compromised (hacked). You can contact your hosting provider, they probably (surely) will not help you. You can contact a web site security company, I use sucuri.net. If you want to clean it yourself, there are 2 options
code9
that shows your code, you can look for this, but probably sometimes it's code9
and sometimes is a different name.