nitoyon/livereloadx — pull request #8 by ngyuki (2014-04-26 11:23:19+00:00)
Title: Add param of port number to injected script tag

Hi.

If specify 80 port option and static mode then livereload does not work.

Example for. create `index.html` and run livereloadx on port 80 and static mode.

```console
$ echo '

foo

' > index.html
$ sudo livereloadx -s -p 80
```

Open `http://localhost:80/` on browser.

```console
$ open http://localhost:80/
```

Look network console of browser. Will show network error.

```
GET http://localhost:35729/livereload ... Aborted!
```

Of course, livereload does not work.

```console
$ echo '

bar

' > index.html
# Not reloaded
```

livereload.js gets src property(not attribute) of script element ...

- https://github.com/nitoyon/livereloadx/blob/v0.3.3/contrib/livereload.js#L345

And, if port number is not found then will use default port.

- https://github.com/nitoyon/livereloadx/blob/v0.3.3/contrib/livereload.js#L349
- https://github.com/nitoyon/livereloadx/blob/v0.3.3/contrib/livereload.js#L320

The browser will omit port 80 of script.src property.

```js
var elem = document.createElement('script');
elem.setAttribute('src', 'http://localhost:80/livereload.js');
console.log(elem.getAttribute('src')); // -> http://localhost:80/livereload.js
console.log(elem.src); // -> http://localhost/livereload.js
```

Therefore, will be used port 35729 of default .

---

I think this is bug of livereload.js.

- https://github.com/livereload/livereload-js/blob/v2.0.8/dist/livereload.js#L345
- https://github.com/livereload/livereload-js/blob/v2.0.8/dist/livereload.js#L349
- https://github.com/livereload/livereload-js/blob/v2.0.8/dist/livereload.js#L320

But, you can easy be fix it by port param of query string.

- https://github.com/livereload/livereload-js/blob/v2.0.8/README.md#user-content-using-livereloadjs

> It also understands some options from the query string: host, port, snipver, mindelay and maxdelay.

I tried to fix query string in injected script tag.

Would you mind review this code?