Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: safari/include.youtube.js

Issue 6304200141045760: Fix issue with comments and thumbnails not loading on YouTube in Safari (Closed)
Patch Set: Created Feb. 28, 2014, 9:38 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <http://adblockplus.org/>, 2 * This file is part of Adblock Plus <http://adblockplus.org/>,
3 * Copyright (C) 2006-2013 Eyeo GmbH 3 * Copyright (C) 2006-2013 Eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 } 60 }
61 61
62 if (flashvarsChanged) 62 if (flashvarsChanged)
63 player.parentNode.replaceChild(newPlayer, player); 63 player.parentNode.replaceChild(newPlayer, player);
64 64
65 // if history.pushState is available, YouTube uses the history API 65 // if history.pushState is available, YouTube uses the history API
66 // when navigation from one video to another, and tells the flash 66 // when navigation from one video to another, and tells the flash
67 // player with JavaScript which video and which ads to show next, 67 // player with JavaScript which video and which ads to show next,
68 // bypassing our flashvars rewrite code. So we disable 68 // bypassing our flashvars rewrite code. So we disable
69 // history.pushState on pages with YouTube's flash player. 69 // history.pushState on pages with YouTube's flash player.
70 document.location.href = "javascript:void(history.pushState = undefined);"; 70 var script = document.createElement("script");
71 script.type = "application/javascript";
72 script.id = "__disablePushState";
73 script.textContent = "history.pushState = undefined;" +
74 "document.documentElement.removeChild(document.getEleme ntById('__disablePushState'));";
Sebastian Noack 2014/02/28 21:54:22 In the previous review Wladimir suggested that we
Wladimir Palant 2014/03/03 07:21:13 Why have the script remove itself? Using |script.a
Sebastian Noack 2014/03/05 11:24:01 Done.
75 document.documentElement.appendChild(script);
71 } 76 }
72 77
73 var deferred = []; 78 var deferred = [];
74 function patchPlayerDeferred(player) 79 function patchPlayerDeferred(player)
75 { 80 {
76 deferred.push(player); 81 deferred.push(player);
77 } 82 }
78 83
79 var onBeforeLoadYoutubeVideo = patchPlayerDeferred; 84 var onBeforeLoadYoutubeVideo = patchPlayerDeferred;
80 function onBeforeLoad(event) 85 function onBeforeLoad(event)
81 { 86 {
82 if ((event.target.localName == "object" || event.target.localName == "embed" ) && /:\/\/[^\/]*\.ytimg\.com\//.test(event.url)) 87 if ((event.target.localName == "object" || event.target.localName == "embed" ) && /:\/\/[^\/]*\.ytimg\.com\//.test(event.url))
83 onBeforeLoadYoutubeVideo(event.target); 88 onBeforeLoadYoutubeVideo(event.target);
84 } 89 }
85 90
86 ext.backgroundPage.sendMessage({type: "get-domain-enabled-state"}, function(re sponse) 91 ext.backgroundPage.sendMessage({type: "get-domain-enabled-state"}, function(re sponse)
87 { 92 {
88 if (response.enabled) 93 if (response.enabled)
89 { 94 {
90 deferred.forEach(patchPlayer); 95 deferred.forEach(patchPlayer);
91 onBeforeLoadYoutubeVideo = patchPlayer; 96 onBeforeLoadYoutubeVideo = patchPlayer;
92 } 97 }
93 else 98 else
94 document.removeEventListener("beforeload", onBeforeLoad); 99 document.removeEventListener("beforeload", onBeforeLoad);
95 }); 100 });
96 101
97 document.addEventListener("beforeload", onBeforeLoad, true); 102 document.addEventListener("beforeload", onBeforeLoad, true);
98 })(); 103 })();
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld