Left: | ||
Right: |
LEFT | RIGHT |
---|---|
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-2014 Eyeo GmbH | 3 * Copyright (C) 2006-2014 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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
91 // player with JavaScript which video and which ads to show next, | 91 // player with JavaScript which video and which ads to show next, |
92 // bypassing our flashvars rewrite code. So we disable | 92 // bypassing our flashvars rewrite code. So we disable |
93 // history.pushState before YouTube's JavaScript runs. | 93 // history.pushState before YouTube's JavaScript runs. |
94 History.prototype.pushState = undefined; | 94 History.prototype.pushState = undefined; |
95 | 95 |
96 // The HTML5 player is configured via ytplayer.config.args. We have | 96 // 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. | 97 // to make sure that ad-related arguments are ignored as they are set. |
98 var ytplayer = undefined; | 98 var ytplayer = undefined; |
99 Object.defineProperty(window, "ytplayer", | 99 Object.defineProperty(window, "ytplayer", |
100 { | 100 { |
101 configurable: true, | |
101 get: function() | 102 get: function() |
102 { | 103 { |
103 return ytplayer; | 104 return ytplayer; |
104 }, | 105 }, |
105 set: function(rawYtplayer) | 106 set: function(rawYtplayer) |
106 { | 107 { |
107 if (!rawYtplayer || typeof rawYtplayer != "object") | 108 if (!rawYtplayer || typeof rawYtplayer != "object") |
108 { | 109 { |
109 ytplayer = rawYtplayer; | 110 ytplayer = rawYtplayer; |
110 return; | 111 return; |
111 } | 112 } |
112 | 113 |
113 var config = undefined; | 114 var config = undefined; |
114 ytplayer = { | 115 ytplayer = Object.create(rawYtplayer, { |
115 __proto__: rawYtplayer, | 116 config: { |
116 get config() | 117 enumerable: true, |
Wladimir Palant
2014/08/29 20:37:07
Given that __proto__ is deprecated, I wonder wheth
Sebastian Noack
2014/08/29 20:45:05
We don't use Object.create() so far in this codeba
Sebastian Noack
2014/08/30 11:03:14
Done.
| |
117 { | 118 get: function() |
118 return config; | |
119 }, | |
120 set config(rawConfig) | |
121 { | |
122 if (!rawConfig || typeof rawConfig != "object") | |
123 { | 119 { |
124 config = rawConfig; | 120 return config; |
125 return; | 121 }, |
122 set: function(rawConfig) | |
123 { | |
124 if (!rawConfig || typeof rawConfig != "object") | |
125 { | |
126 config = rawConfig; | |
127 return; | |
128 } | |
129 | |
130 var args = undefined; | |
131 config = Object.create(rawConfig, { | |
132 args: { | |
133 enumerable: true, | |
134 get: function() | |
135 { | |
136 return args; | |
137 }, | |
138 set: function(rawArgs) | |
139 { | |
140 if (!rawArgs || typeof rawArgs != "object") | |
141 { | |
142 args = rawArgs; | |
143 return; | |
144 } | |
145 | |
146 args = {}; | |
147 for (var arg in rawArgs) | |
148 { | |
149 if (!badArgumentsRegex.test(arg)) | |
150 args[arg] = rawArgs[arg]; | |
151 } | |
152 } | |
153 } | |
154 }); | |
155 | |
156 config.args = rawConfig.args; | |
126 } | 157 } |
127 | |
128 var args = undefined; | |
129 config = { | |
130 __proto__: rawConfig, | |
131 get args() | |
132 { | |
133 return args; | |
134 }, | |
135 set args(rawArgs) | |
136 { | |
137 if (!rawArgs || typeof rawArgs != "object") | |
138 { | |
139 args = rawArgs; | |
140 return; | |
141 } | |
142 | |
143 args = {}; | |
144 for (var arg in rawArgs) | |
145 { | |
146 if (!badArgumentsRegex.test(arg)) | |
147 args[arg] = rawArgs[arg]; | |
148 } | |
149 } | |
150 }; | |
151 | |
152 config.args = rawConfig.args; | |
153 } | 158 } |
154 }; | 159 }); |
155 | 160 |
156 ytplayer.config = rawYtplayer.config; | 161 ytplayer.config = rawYtplayer.config; |
157 }, | 162 } |
158 configurable: true | |
159 }); | 163 }); |
160 }, badArgumentsRegex); | 164 }, badArgumentsRegex); |
161 })(); | 165 })(); |
LEFT | RIGHT |