use ajax to fetch the url that contains the code.
then, search the response using regexp or dom methods.
for example, i recently moved an old-school form to an ajax form, but needed a dynamic id to prevent the submitted form from being rejected.
ajax callback snip to update hard-coded form with remote value:
in that case, i was matching an input on the remote "real" page that was coded like:
<input type="hidden" name="XID" value="f2090eeb9ccccfb00714e2d377ff5a7d4127b618" />
BROWSER STATS [% share]
(2013/10/31) IE7:0.5, IE8:8.6, IE9:5.3, IE10:12.3, FF:17.7, CH:41.8, SF:8.1, MOBILE:20.4