I took a course on computer privacy law a few years ago, and one of the big questions is "what is privacy"? After looking at all the various philosophical and legal definitions, I came away with this definition: privacy is autotomy -- the right to conduct your affairs without unreasonable and uninvited interference.
So I would define online harassment as deliberate and uninvited interference. Unpleasantness is simply one *means* by which the interference is accomplished, but it is not in and of itself harassment.
Example 1: you make the mistake of delving into Youtube comments. That's like crossing a Norwegian footbridge with a sack of goats. You have chosen to dive into a pool of nastiness, and unpleasant feelings are an unfortunate but non-actionable consequence of that decision.
Example 2: you decide to block some of the more obnoxious trolls. One of them figures this out and creates a new account so he can continue harassing you. Now that's harassment, because you have explicitly un-invited that interaction. He is interfering with your right to ignore him.
Example 3: one of the trolls doxes you and follows you to another website. That's harassment too because his *intent* is to interfere with your enjoyment of that website.
Example 4: You are on a website and someone violates the site's "harassment" policy. This is a matter for the site admins, not the police or courts, unless the person is cyber-stalking you. A reasonable person doesn't expect site policies to be strictly and swiftly enforced -- it almost never happens. By choosing to use any website you choose to expose yourself to obnoxious people.