How about this:
Create a new userprofile field in Admin CP hidden in profile but editable by the users, note its id
Tell your users to enter "YES" there if they want to load the script.
Then edit global.php, find:
PHP Code:
// parse PHP include ##################
Before that add:
PHP Code:
if (strtolower($bbuserinfo[fieldX])=='yes') {$yourjavacode='ENTER CODE HERE';}
(Replace X with your field id)
Then you can use "$yourjavacode" variable in your relavant template like header..