My first tests showed browser caching problems with using JavaScript to change a URL after the visitor clicks on its associated link, but before it is sent to the web server.
I then switched to an approach of using JavaScript to change all links on the webpage right after Page Load, and that seems to work properly.
Of course, that was just appending a fixed ?theme=2012 to every href in a <a>
HTML tag. Now comes all the JavaScript coding to only changes URLs that are part of the WordPress site, handle & v.s. ? query prefixes, make sure that the same keyword is not already present and, of course, obtaining the keyword=value from the cookie. There is also considerable PHP reworking of the plugin.
I'll try and shortcut as much as I can to give you a Proof of Concept version of the plugin as soon as possible. For example, I don't have to write the "is the URL part of the WordPress site?" part until after Proof of Concept.