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

Delta Between Two Patch Sets: safari/include.youtube.js

Issue 6304200141045760: Fix issue with comments and thumbnails not loading on YouTube in Safari (Closed)
Left Patch Set: Created Feb. 28, 2014, 9:38 p.m.
Right Patch Set: Addressed comment Created March 5, 2014, 11:23 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 var script = document.createElement("script"); 70 var script = document.createElement("script");
71 script.type = "application/javascript"; 71 script.type = "application/javascript";
72 script.id = "__disablePushState"; 72 script.async = false;
73 script.textContent = "history.pushState = undefined;" + 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); 74 document.documentElement.appendChild(script);
75 document.documentElement.removeChild(script);
76 } 76 }
77 77
78 var deferred = []; 78 var deferred = [];
79 function patchPlayerDeferred(player) 79 function patchPlayerDeferred(player)
80 { 80 {
81 deferred.push(player); 81 deferred.push(player);
82 } 82 }
83 83
84 var onBeforeLoadYoutubeVideo = patchPlayerDeferred; 84 var onBeforeLoadYoutubeVideo = patchPlayerDeferred;
85 function onBeforeLoad(event) 85 function onBeforeLoad(event)
86 { 86 {
87 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))
88 onBeforeLoadYoutubeVideo(event.target); 88 onBeforeLoadYoutubeVideo(event.target);
89 } 89 }
90 90
91 ext.backgroundPage.sendMessage({type: "get-domain-enabled-state"}, function(re sponse) 91 ext.backgroundPage.sendMessage({type: "get-domain-enabled-state"}, function(re sponse)
92 { 92 {
93 if (response.enabled) 93 if (response.enabled)
94 { 94 {
95 deferred.forEach(patchPlayer); 95 deferred.forEach(patchPlayer);
96 onBeforeLoadYoutubeVideo = patchPlayer; 96 onBeforeLoadYoutubeVideo = patchPlayer;
97 } 97 }
98 else 98 else
99 document.removeEventListener("beforeload", onBeforeLoad); 99 document.removeEventListener("beforeload", onBeforeLoad);
100 }); 100 });
101 101
102 document.addEventListener("beforeload", onBeforeLoad, true); 102 document.addEventListener("beforeload", onBeforeLoad, true);
103 })(); 103 })();
LEFTRIGHT
« no previous file | no next file » | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
This is Rietveld