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

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

Issue 29338588: Issue 3699 - Patch DOM API in order to prevent disabling the injected stylesheet (Closed)
Patch Set: Created March 17, 2016, 7:47 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 | « include.preload.js ('k') | 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 <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2016 Eyeo GmbH 3 * Copyright (C) 2006-2016 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 param.setAttribute("value", newValue); 61 param.setAttribute("value", newValue);
62 flashvarsChanged = true; 62 flashvarsChanged = true;
63 } 63 }
64 } 64 }
65 } 65 }
66 66
67 if (flashvarsChanged) 67 if (flashvarsChanged)
68 player.parentNode.replaceChild(newPlayer, player); 68 player.parentNode.replaceChild(newPlayer, player);
69 } 69 }
70 70
71 function runInPage(fn, arg)
72 {
73 var script = document.createElement("script");
74 script.type = "application/javascript";
75 script.async = false;
76 script.textContent = "(" + fn + ")(" + arg + ");";
77 document.documentElement.appendChild(script);
78 document.documentElement.removeChild(script);
79 }
80
81 document.addEventListener("beforeload", function(event) 71 document.addEventListener("beforeload", function(event)
82 { 72 {
83 if ((event.target.localName == "object" || event.target.localName == "embed" ) && /:\/\/[^\/]*\.ytimg\.com\//.test(event.url)) 73 if ((event.target.localName == "object" || event.target.localName == "embed" ) && /:\/\/[^\/]*\.ytimg\.com\//.test(event.url))
84 patchPlayer(event.target); 74 patchPlayer(event.target);
85 }, true); 75 }, true);
86 76
87 runInPage(function(badArgumentsRegex) 77 runInPage(document, badArgumentsRegex, function(badArgumentsRegex)
88 { 78 {
89 // If history.pushState is available, YouTube uses the history API 79 // If history.pushState is available, YouTube uses the history API
90 // when navigation from one video to another, and tells the flash 80 // when navigation from one video to another, and tells the flash
91 // player with JavaScript which video and which ads to show next, 81 // player with JavaScript which video and which ads to show next,
92 // bypassing our flashvars rewrite code. So we disable 82 // bypassing our flashvars rewrite code. So we disable
93 // history.pushState before YouTube's JavaScript runs. 83 // history.pushState before YouTube's JavaScript runs.
94 History.prototype.pushState = undefined; 84 History.prototype.pushState = undefined;
95 85
96 // The HTML5 player is configured via ytplayer.config.args. We have 86 // The HTML5 player is configured via ytplayer.config.args. We have
97 // to make sure that ad-related arguments are ignored as they are set. 87 // to make sure that ad-related arguments are ignored as they are set.
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 }); 144 });
155 145
156 config.args = rawConfig.args; 146 config.args = rawConfig.args;
157 } 147 }
158 } 148 }
159 }); 149 });
160 150
161 ytplayer.config = rawYtplayer.config; 151 ytplayer.config = rawYtplayer.config;
162 } 152 }
163 }); 153 });
164 }, badArgumentsRegex); 154 });
165 })(); 155 })();
OLDNEW
« no previous file with comments | « include.preload.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld