Index: safari/include.youtube.js |
=================================================================== |
--- a/safari/include.youtube.js |
+++ b/safari/include.youtube.js |
@@ -19,6 +19,8 @@ |
if (document.domain != "www.youtube.com") |
return; |
+ pushStateDisabled = false; |
+ |
function rewriteFlashvars(flashvars) |
{ |
var pairs = flashvars.split("&"); |
@@ -61,6 +63,21 @@ |
if (flashvarsChanged) |
player.parentNode.replaceChild(newPlayer, player); |
+ |
+ // if history.pushState is available, YouTube uses the history API |
+ // when navigation from one video to another, and tells the flash |
+ // player with JavaScript which video and which ads to show next, |
+ // bypassing our flashvars rewrite code. So we disable |
+ // history.pushState on pages with YouTube's flash player. |
+ if (!pushStateDisabled) |
+ { |
+ var script = document.createElement("script"); |
+ script.type = "application/javascript"; |
+ script.textContent = "history.pushState = undefined;"; |
+ document.documentElement.appendChild(script); |
Wladimir Palant
2014/02/24 13:15:03
We shouldn't leave this script around, it needs to
Sebastian Noack
2014/02/24 14:32:09
Done.
|
+ |
+ pushStateDisabled = true; |
Wladimir Palant
2014/02/24 13:15:03
Why is this flag necessary? Content scripts should
Sebastian Noack
2014/02/24 14:32:09
Yes, but the code runs per player loaded. However
|
+ } |
} |
var deferred = []; |