OLD | NEW |
1 /* | 1 /* This Source Code Form is subject to the terms of the Mozilla Public |
2 * This file is part of the Adblock Plus build tools, | 2 * License, v. 2.0. If a copy of the MPL was not distributed with this |
3 * Copyright (C) 2006-2014 Eyeo GmbH | 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
4 * | |
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 | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * Adblock Plus is distributed in the hope that it will be useful, | |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 * GNU General Public License for more details. | |
13 * | |
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/>. | |
16 */ | |
17 | 4 |
18 function hook(obj, name, func, cleanup) | 5 function hook(obj, name, func, cleanup) |
19 { | 6 { |
20 let orig = obj[name]; | 7 let orig = obj[name]; |
21 let origGet = obj.__lookupGetter__(name); | 8 let origGet = obj.__lookupGetter__(name); |
22 let origSet = obj.__lookupSetter__(name); | 9 let origSet = obj.__lookupSetter__(name); |
23 let dumbOverrideAttempt = false; | 10 let dumbOverrideAttempt = false; |
24 | 11 |
25 let newFunc = function() | 12 let newFunc = function() |
26 { | 13 { |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 { | 71 { |
85 obj.__defineGetter__(name, origGet); | 72 obj.__defineGetter__(name, origGet); |
86 } | 73 } |
87 if (origSet) | 74 if (origSet) |
88 { | 75 { |
89 obj.__defineSetter__(name, origSet); | 76 obj.__defineSetter__(name, origSet); |
90 } | 77 } |
91 }; | 78 }; |
92 } | 79 } |
93 exports.hook = hook; | 80 exports.hook = hook; |
OLD | NEW |