watched videos are now marked as visited

Using a bitfield in the localStorage to save which video links were clicked on.
Also some minor cleanup in the js file and some more results with casts.