OLD | NEW |
1 /* | 1 /* |
2 * This file is part of the URL Fixer, | 2 * This file is part of the URL Fixer, |
3 * Copyright (C) 2006-2015 Eyeo GmbH | 3 * Copyright (C) 2006-2015 Eyeo GmbH |
4 * | 4 * |
5 * URL Fixer is free software: you can redistribute it and/or modify | 5 * URL Fixer 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 * URL Fixer is distributed in the hope that it will be useful, | 9 * URL Fixer 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 17 matching lines...) Expand all Loading... |
28 unhook(); | 28 unhook(); |
29 functionHooks.delete(window); | 29 functionHooks.delete(window); |
30 } | 30 } |
31 }; | 31 }; |
32 | 32 |
33 switch (addonName) | 33 switch (addonName) |
34 { | 34 { |
35 case "url-fixer": | 35 case "url-fixer": |
36 { | 36 { |
37 // URL Fixer | 37 // URL Fixer |
38 exports.isTypoCorrectionEnabled = function(window, prefix, domain, suffix) t
rue; | 38 exports.isTypoCorrectionEnabled = (window, prefix, domain, suffix) => true; |
39 | 39 |
40 break; | 40 break; |
41 } | 41 } |
42 case "adblockplus": | 42 case "adblockplus": |
43 { | 43 { |
44 // Adblock Plus | 44 // Adblock Plus |
45 let {Prefs} = require("prefs"); | 45 let {Prefs} = require("prefs"); |
46 | 46 |
47 // Do not ask to opt-in if user found setting | 47 // Do not ask to opt-in if user found setting |
48 if (!Prefs.correctTyposAsked) | 48 if (!Prefs.correctTyposAsked) |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 | 98 |
99 break; | 99 break; |
100 } | 100 } |
101 } | 101 } |
102 | 102 |
103 switch (application) | 103 switch (application) |
104 { | 104 { |
105 case "firefox": | 105 case "firefox": |
106 { | 106 { |
107 // Firefox | 107 // Firefox |
108 exports.isKnownWindow = function(window) window.document.documentElement.get
Attribute("windowtype") == "navigator:browser"; | 108 exports.isKnownWindow = (window) => window.document.documentElement.getAttri
bute("windowtype") == "navigator:browser"; |
109 | 109 |
110 exports.getURLBar = function(window) "gURLBar" in window ? window.gURLBar :
null; | 110 exports.getURLBar = (window) => "gURLBar" in window ? window.gURLBar : null; |
111 | 111 |
112 exports.getBrowser = function(window) "gBrowser" in window ? window.gBrowser
: null; | 112 exports.getBrowser = (window) => "gBrowser" in window ? window.gBrowser : nu
ll; |
113 | 113 |
114 exports.applyToWindow = function(window, corrector) | 114 exports.applyToWindow = function(window, corrector) |
115 { | 115 { |
116 let urlbar = exports.getURLBar(window); | 116 let urlbar = exports.getURLBar(window); |
117 if (urlbar && urlbar.handleCommand && !functionHooks.has(window)) | 117 if (urlbar && urlbar.handleCommand && !functionHooks.has(window)) |
118 { | 118 { |
119 // Handle new URLs being entered | 119 // Handle new URLs being entered |
120 let unhook = hook(urlbar, "handleCommand", function() | 120 let unhook = hook(urlbar, "handleCommand", function() |
121 { | 121 { |
122 let correction = corrector(window, urlbar.value); | 122 let correction = corrector(window, urlbar.value); |
(...skipping 29 matching lines...) Expand all Loading... |
152 exports.getBrowser(window).loadURI(uri); | 152 exports.getBrowser(window).loadURI(uri); |
153 }; | 153 }; |
154 | 154 |
155 break; | 155 break; |
156 } | 156 } |
157 case "seamonkey": | 157 case "seamonkey": |
158 { | 158 { |
159 let eventListeners = new WeakMap(); | 159 let eventListeners = new WeakMap(); |
160 | 160 |
161 // SeaMonkey | 161 // SeaMonkey |
162 exports.isKnownWindow = function(window) window.document.documentElement.get
Attribute("windowtype") == "navigator:browser"; | 162 exports.isKnownWindow = (window) => window.document.documentElement.getAttri
bute("windowtype") == "navigator:browser"; |
163 | 163 |
164 exports.getURLBar = function(window) "gURLBar" in window ? window.gURLBar :
null; | 164 exports.getURLBar = (window) => "gURLBar" in window ? window.gURLBar : null; |
165 | 165 |
166 exports.getBrowser = function(window) "gBrowser" in window ? window.gBrowser
: null; | 166 exports.getBrowser = (window) => "gBrowser" in window ? window.gBrowser : nu
ll; |
167 | 167 |
168 exports.applyToWindow = function(window, corrector) | 168 exports.applyToWindow = function(window, corrector) |
169 { | 169 { |
170 let urlbar = exports.getURLBar(window); | 170 let urlbar = exports.getURLBar(window); |
171 let goButton = window.document.getElementById("go-button-container"); | 171 let goButton = window.document.getElementById("go-button-container"); |
172 | 172 |
173 if (urlbar && urlbar._fireEvent && !functionHooks.has(window)) | 173 if (urlbar && urlbar._fireEvent && !functionHooks.has(window)) |
174 { | 174 { |
175 let correctURL = function() | 175 let correctURL = function() |
176 { | 176 { |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 exports.loadURI = function(window, uri) | 236 exports.loadURI = function(window, uri) |
237 { | 237 { |
238 exports.getBrowser(window).loadURI(uri); | 238 exports.getBrowser(window).loadURI(uri); |
239 }; | 239 }; |
240 | 240 |
241 break; | 241 break; |
242 } | 242 } |
243 case "fennec": | 243 case "fennec": |
244 { | 244 { |
245 // XUL Fennec | 245 // XUL Fennec |
246 exports.isKnownWindow = function(window) window.document.documentElement.get
Attribute("windowtype") == "navigator:browser"; | 246 exports.isKnownWindow = (window) => window.document.documentElement.getAttri
bute("windowtype") == "navigator:browser"; |
247 | 247 |
248 exports.getURLBar = function(window) null; | 248 exports.getURLBar = (window) => null; |
249 | 249 |
250 exports.getBrowser = function(window) null; | 250 exports.getBrowser = (window) => null; |
251 | 251 |
252 exports.applyToWindow = function(window, corrector) | 252 exports.applyToWindow = function(window, corrector) |
253 { | 253 { |
254 if ("BrowserUI" in window && window.BrowserUI.goToURI && !functionHooks.ha
s(window)) | 254 if ("BrowserUI" in window && window.BrowserUI.goToURI && !functionHooks.ha
s(window)) |
255 { | 255 { |
256 // Handle new URLs being entered | 256 // Handle new URLs being entered |
257 let unhook = hook(window.BrowserUI, "goToURI", function(url) | 257 let unhook = hook(window.BrowserUI, "goToURI", function(url) |
258 { | 258 { |
259 url = url || this._edit.value; | 259 url = url || this._edit.value; |
260 | 260 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
297 { | 297 { |
298 window.BrowserUI.goToURI(uri); | 298 window.BrowserUI.goToURI(uri); |
299 } | 299 } |
300 }; | 300 }; |
301 | 301 |
302 break; | 302 break; |
303 } | 303 } |
304 case "fennec2": | 304 case "fennec2": |
305 { | 305 { |
306 // Native Fennec | 306 // Native Fennec |
307 exports.isKnownWindow = function(window) window.document.documentElement.get
Attribute("windowtype") == "navigator:browser"; | 307 exports.isKnownWindow = (window) => window.document.documentElement.getAttri
bute("windowtype") == "navigator:browser"; |
308 | 308 |
309 exports.getURLBar = function(window) null; | 309 exports.getURLBar = (window) => null; |
310 | 310 |
311 exports.getBrowser = function(window) null; | 311 exports.getBrowser = (window) => null; |
312 | 312 |
313 exports.applyToWindow = function(window, corrector) | 313 exports.applyToWindow = function(window, corrector) |
314 { | 314 { |
315 if ("BrowserApp" in window && window.BrowserApp.observe && !functionHooks.
has(window)) | 315 if ("BrowserApp" in window && window.BrowserApp.observe && !functionHooks.
has(window)) |
316 { | 316 { |
317 let innerUnhook = null; | 317 let innerUnhook = null; |
318 let cleanup = function() | 318 let cleanup = function() |
319 { | 319 { |
320 if (innerUnhook) | 320 if (innerUnhook) |
321 innerUnhook(); | 321 innerUnhook(); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 exports.loadURI = function(window, uri) | 365 exports.loadURI = function(window, uri) |
366 { | 366 { |
367 if ("BrowserApp" in window && "loadURI" in window.BrowserApp) | 367 if ("BrowserApp" in window && "loadURI" in window.BrowserApp) |
368 window.BrowserApp.loadURI(uri); | 368 window.BrowserApp.loadURI(uri); |
369 }; | 369 }; |
370 | 370 |
371 break; | 371 break; |
372 } | 372 } |
373 default: | 373 default: |
374 { | 374 { |
375 exports.isKnownWindow = function(window) false; | 375 exports.isKnownWindow = (window) => false; |
376 break; | 376 break; |
377 } | 377 } |
378 } | 378 } |
OLD | NEW |