Left: | ||
Right: |
OLD | NEW |
---|---|
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 |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
13 * | 13 * |
14 * You should have received a copy of the GNU General Public License | 14 * You should have received a copy of the GNU General Public License |
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
16 */ | 16 */ |
17 | 17 |
18 (function() { | 18 (function() { |
19 if (document.domain != "www.youtube.com") | 19 if (document.domain != "www.youtube.com") |
20 return; | 20 return; |
21 | 21 |
22 var usingContentBlockerAPI = true; | |
23 try | |
24 { | |
25 if (safari.self.tab.canLoad(beforeLoadEvent, | |
26 {category: "request", | |
27 payload: {type: "prefs.get", | |
28 key: "safariContentBlocker"}}) != tru e) | |
29 usingContentBlockerAPI = false; | |
30 } | |
31 catch (e) { }; | |
Sebastian Noack
2016/05/17 18:35:26
Nit: Redundant semicolon.
Also I wonder whether w
kzar
2016/05/17 19:20:23
Done.
| |
32 | |
33 if (usingContentBlockerAPI) | |
34 return; | |
35 | |
22 if (ext.backgroundPage.sendMessageSync({type: "filters.isPageWhitelisted"})) | 36 if (ext.backgroundPage.sendMessageSync({type: "filters.isPageWhitelisted"})) |
23 return; | 37 return; |
24 | 38 |
25 var badArgumentsRegex = /^((.*_)?(ad|ads|afv|adsense)(_.*)?|(ad3|st)_module|pr erolls|interstitial|infringe|iv_cta_url)$/; | 39 var badArgumentsRegex = /^((.*_)?(ad|ads|afv|adsense)(_.*)?|(ad3|st)_module|pr erolls|interstitial|infringe|iv_cta_url)$/; |
26 | 40 |
27 function rewriteFlashvars(flashvars) | 41 function rewriteFlashvars(flashvars) |
28 { | 42 { |
29 var pairs = flashvars.split("&"); | 43 var pairs = flashvars.split("&"); |
30 for (var i = 0; i < pairs.length; i++) | 44 for (var i = 0; i < pairs.length; i++) |
31 if (badArgumentsRegex.test(pairs[i].split("=")[0])) | 45 if (badArgumentsRegex.test(pairs[i].split("=")[0])) |
32 pairs.splice(i--, 1); | 46 pairs.splice(i--, 1); |
33 return pairs.join("&"); | 47 return pairs.join("&"); |
34 } | 48 } |
35 | 49 |
36 function patchPlayer(player) | 50 function patchPlayer(player) |
37 { | 51 { |
38 var newPlayer = player.cloneNode(true); | 52 var newPlayer = player.cloneNode(true); |
39 var flashvarsChanged = false; | 53 var flashvarsChanged = false; |
40 | 54 |
41 var flashvars = newPlayer.getAttribute("flashvars"); | 55 var flashvars = newPlayer.getAttribute("flashvars"); |
42 if (flashvars) | 56 if (flashvars) |
43 { | 57 { |
44 var newFlashvars = rewriteFlashvars(flashvars); | 58 var newFlashvars = rewriteFlashvars(flashvars); |
45 if (flashvars != newFlashvars) | 59 if (flashvars != newFlashvars) |
46 { | 60 { |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
156 config.args = rawConfig.args; | 170 config.args = rawConfig.args; |
157 } | 171 } |
158 } | 172 } |
159 }); | 173 }); |
160 | 174 |
161 ytplayer.config = rawYtplayer.config; | 175 ytplayer.config = rawYtplayer.config; |
162 } | 176 } |
163 }); | 177 }); |
164 }, badArgumentsRegex); | 178 }, badArgumentsRegex); |
165 })(); | 179 })(); |
OLD | NEW |