Is there a way for the user to get browsers to load a (small) piece of Javascript code for every page they view?
Depends on the browser. In Opera you can use UserJS to do this, and a user can specify where it applies and what it does. It is entirely up to the user to set this up. This can be used for overriding annoying behaviour on a site, adding your own customisations (until Opera 10, UserJS was the most common way of incorporating automatic spell-checking), or getting sites to work (Opera use a file called Browser.js for this to help make broken/buggy/unfriendly sites work in the browser)
The user can do it with a firefox plugin, called greasemonkey. The server cant do that.
If you really wanted to, you could probably let them submit their JS, store it, and run it with PHP. I didn't really test that out, but this little snippet worked, so I'd imagine you could do it:
<?php
$js = <<< HERE
<script type="text/javascript">
document.write("hello world");
</script>
HERE;
echo $js;
?>