I understand that by the time Selenium can interact with the page, it is already loaded, which means that you cannot add something to the <head> element.
You can use runScript to dynamically add a script tag to the head element using the DOM manipulation methods, but this is probably not what you are after ...
source
share