gazza911 / Autocomplete with Cache

Published:

Version: 1.02+50c5506 updated

Summary: Adds an autocomplete with local cache (that also acts an as optional search history) to TVMaze

License: MIT

Example search result

How to install

Firefox users: Download Greasemonkey
Chrome users: Download Tampermonkey

Click the blue 'Install' button on OpenUserJS and follow the on-screen instructions

Instructions / Notes

This autocomplete uses the TVMaze API and will not be any more accurate than if you had searched for it; like the normal search, this is limited to the top 10 results.

If a show is added/updated then you'll have to delete it from the cache in order to see the updated version - there's also a delay between the standard search and the API, this is out of my control as it is server side.

The cache is local meaning that no-one else (including me, the developer) will be able to see your search history - any data that might be collected by TVMaze when using the API is also out of my control.

Aside from being used for a search history, the cache has been included so that when repeating the same search (i.e you often search for the same tv show) it doesn't have to make another request to TVMaze (you already have the required information) making both the load time quicker (especially if you have a slow connection) and reduces the load for TVMaze - note: so that this is not detrimental to TVMaze, it will not search for it until 0.5 seconds after you stop typing to prevent it from making lots of requests if you don't type fast enough... being Open source someone can obviously change this, but I'd recommend keeping it above at least 300ms (0.3 seconds) otherwise you may be sending a request after every letter you type - it will also not start searching until you've typed at least 4 characters (this can include spaces).

Any images used are licensed so that they do not require a link-back and thus have been converted to base64 so that the images do not have to be stored anywhere.

To delete all settings/search history:

1. Change line #49 - which is normally reset(false); - to reset(true);
2. Reload any page on TVMaze once
3. Change it back to reset(false);

To delete individual searches:

1. Select the search you want to delete from the dropdown
2. Click the grey 'X' to the right of the dropdown

Annotated example showing how to delete a search

To hide/show search history:

1. Click the up/down arrow just below the search - when hidden, search results will still be stored for caching purposes but will not be displayed

Annotated example showing how to show/hide your search history

To change the cache time (how long each search result is stored) :

1. Change the value of 'longevity' (line #50) - this is the number of days, but any value including 0.5 for half a day would be accepted

To see previous search results without typing it in again:

1. Select the show/person you want to see the search results for from the dropdown

Annotated example showing how to show previous search result

Rating: 0