Script blocks are executed top to bottom as the browser encounters them while parsing the document. So you can't use code in the first script to manipulate any elements after that script. You are trying to replace a script element that appears after.
But why try to replace the script at all? Why not just put the logic in the script:
var ua = navigator.userAgent.toLowerCase();
var isSafari = ua.indexOf('safari') != -1 && ua.indexOf('chrome') == -1;
function updateTitle() {
if (isSafari) {
document.getElementsByTagName("title")[0].innerHTML = "Uppagus";
} else {
setTimeout(function() {
document.getElementsByTagName('title')[0].innerHTML = 'ppagus';
}, 2000);
}
}
(Note also that your nested if/else structure is more complicated than necessary.)