Use protocol relative URLs and document.URL

Commit messages have all the details, but in short, github supports protocol relative URLs, so use them, and location.href is buggy, so use document.URL instead.