Why did you add userSelection == "[object TextRange]" ?
I consider things working in "all browsers" if they do in Firefox, Chrome, Opera, and Internet Explorer 6+, but you'll have to check that yourself :)
Search before you ask, please, and stop asking for a link, there are search engines for that.
As another hint, throw the selection object at console.log() and look at the properties it has. That should help.