I've had an embarrassingly long non-romantic obsession with someone, though it didn't involve a bf. I think I'm nearly over it now. This is what helped me:
Looking at them objectively. A lot of what I thought was amazing about them were things I had exaggerated or assumed in my own head. I realized I don't actually like this person and they are pretty dumb. Why was I spending so much time thinking about them?
Realizing they are a compulsive liar. This is why everything always seemed perfect for them. Everyone lies to a degree but some do it much more than others. Unless you can verify it elsewhere, assume everything has an element of deception.
Building up my own life. It's very hard to be envious of X when I have X in my own backyard. I tried some of thing things I was envious of and realized I didn't actually want that thing! I just liked the idea. I also explored more of my own wishes unrelated to them. Gaining skills and qualifications helped me build self worth too.
Removing the negative elements of my life. Doing this meant I was less likely to look for a fantasy escape to obsess over.
Realizing that we didn't have the same start in life. They had a privileged upbringing. I had an abusive one. That doesn't mean they are better. It's interesting to see them struggle with things now that I learned to take in my stride from a young age.
Stop checking and delete everything. It's normal to take a few attempts to be able to stop but each attempt will become easier and easier. At first just a day was torture but now I can months easily. Keeping busy with various personal projects helps a lot.