The code for this needs major cleanup.
"var $ = document; // shortcut" may kill jQuery and break your site.
This also declares the following global namespaces variables: cssId, head, and link.
The code is hosted on an untrusted amazon instance, so requires a bit of work to crawl the links and copy paste the source for self-hosting and security needs. Cool idea though. Put this on Github if you want code fixes.