For 1&2, you can use an httpclass (pre v11.4) or a policy (11.4+) to do that, no iRule necessary.
For 3, google would need to rewrite that ajax call, the request isn’t coming to your domain. However, assuming it’s your app that is inserting that, you can use a stream profile to rewrite that URL to ssl. You can try this (untested, check out and tune as necessary in lab environment)
when HTTP_RESPONSE {
STREAM::disable
set stream_expression "";
if { ( ([HTTP::header Content-Type] starts_with "text/html") && ([HTTP::status] == 200) } {
set stream_expression "@http://www.youtube.com@@"
}
if { "" ne $stream_expression } {
STREAM::expression $stream_expression
STREAM::enable
}
}
when STREAM_MATCHED {
if { [string tolower [STREAM::match]] eq “http://www.youtube.com” } {
STREAM::replace “https://www.youtube.com”
}
}