Interesting problem. Yes you can do it but you need to cache the querystring and then recreate it.
You need two scripts;
one on your password page that captures a querystring and writes it to sessionStorage
one on your target pages ( any pages behind that password protection screen that need the querystring ) which checks sessionStorage, and then re-applies the querystring to the URL.
From there, it’s accessible by scripts for whatever you’re doing.
Note I’d make these little scripts synchronous and put them in the HEAD code area so that they run before any any scripts that might be using that querystring data.