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

Delta Between Two Patch Sets: safari/ext/content.js

Issue 29829615: Issue 6786 - Switch Safari 12+ users to content blocking API (Closed)
Left Patch Set: Created July 13, 2018, 6:18 p.m.
Right Patch Set: Simplify Safari version parsing logic Created July 13, 2018, 6:57 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « safari/contentBlocking.js ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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-present eyeo GmbH 3 * Copyright (C) 2006-present 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 { 19 {
20 // the safari object is missing in frames created from javascript: URLs. 20 // the safari object is missing in frames created from javascript: URLs.
21 // So we have to fallback to the safari object from the parent frame. 21 // So we have to fallback to the safari object from the parent frame.
22 if (!("safari" in window)) 22 if (!("safari" in window))
23 window.safari = window.parent.safari; 23 window.safari = window.parent.safari;
24 24
25 25
26 /* Intialization */ 26 /* Intialization */
27 27
28 var applicatonVersion = navigator.userAgent.match(/Version\/([\d.]+)/)[1]; 28 var majorApplicationVersion = parseInt(navigator.userAgent.match(/Version\/([\ d]+)/)[1]);
29 var majorApplicationVersion = parseInt(applicatonVersion.split(".")[0], 10);
30 29
31 var beforeLoadEvent; 30 var beforeLoadEvent;
32 var usingContentBlockerAPI = true; 31 var usingContentBlockerAPI = true;
33 32
34 // Safari 12 automatically disables extensions which use the old canLoad API, 33 // Safari 12 automatically disables extensions which use the old canLoad API,
35 // so avoid using the old APIs on Safari 12! 34 // so avoid using the old APIs on Safari 12!
36 if (majorApplicationVersion < 12) 35 if (majorApplicationVersion < 12)
37 { 36 {
38 beforeLoadEvent = document.createEvent("Event"); 37 beforeLoadEvent = document.createEvent("Event");
39 beforeLoadEvent.initEvent("beforeload", false, true); 38 beforeLoadEvent.initEvent("beforeload", false, true);
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 }); 236 });
238 237
239 238
240 /* Detecting extension reload/disable/uninstall (not supported on Safari) */ 239 /* Detecting extension reload/disable/uninstall (not supported on Safari) */
241 240
242 ext.onExtensionUnloaded = { 241 ext.onExtensionUnloaded = {
243 addListener: function() {}, 242 addListener: function() {},
244 removeListener: function() {} 243 removeListener: function() {}
245 }; 244 };
246 })(); 245 })();
LEFTRIGHT

Powered by Google App Engine
This is Rietveld