[Extensions] Handle some funny cases in script injection