I realize that window.location.href sometimes returns something other than the string displayed in the URL bar. Is there any 开发者_如何学Goway to get the string displayed in the URL bar in Javascript?
When I visit www.google.com using this user script, document.location.href is not always "www.google.com" as expected.
location
has many properties which should allow you to get the part you want. Have a look at its documentation [MDN].
Chrome, by default, hides the protocol of the URI (see also @Andy E's comment).
精彩评论