diff --git a/.gitignore b/.gitignore
index b5ba1f15a..d550bf20c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,3 @@
*.bak
*.pem
-/meta/safariextz/certs/
/dist/build/
\ No newline at end of file
diff --git a/platform/safari/Info.plist b/platform/safari/Info.plist
index 084209322..dab006b6f 100644
--- a/platform/safari/Info.plist
+++ b/platform/safari/Info.plist
@@ -13,7 +13,7 @@
CFBundleInfoDictionaryVersion
6.0
CFBundleShortVersionString
- 0.7.0.11
+ 0.7.2.0
CFBundleVersion
1
Chrome
diff --git a/platform/safari/vapi-background.js b/platform/safari/vapi-background.js
index ee37fe263..9a662f208 100644
--- a/platform/safari/vapi-background.js
+++ b/platform/safari/vapi-background.js
@@ -36,6 +36,13 @@ vAPI.safari = true;
/******************************************************************************/
+vAPI.app = {
+ name: 'µBlock',
+ version: '0.7.2.0'
+};
+
+/******************************************************************************/
+
// addContentScriptFromURL allows whitelisting,
// so load sitepaching this way, instead of adding it to the Info.plist
@@ -568,10 +575,32 @@ vAPI.messaging.broadcast = function(message) {
/******************************************************************************/
-vAPI.net = {}
+safari.application.addEventListener('beforeNavigate', function(e) {
+ if (!vAPI.tabs.expectPopUpFrom || e.url === 'about:blank') {
+ return;
+ }
+
+ var details = {
+ url: e.url,
+ tabId: vAPI.tabs.getTabId(e.target),
+ sourceTabId: vAPI.tabs.expectPopUpFrom
+ };
+
+ vAPI.tabs.expectPopUpFrom = null;
+
+ if (vAPI.tabs.onPopup(details)) {
+ e.preventDefault();
+
+ if (vAPI.tabs.stack[details.sourceTabId]) {
+ vAPI.tabs.stack[details.sourceTabId].activate();
+ }
+ }
+}, true);
/******************************************************************************/
+vAPI.net = {}
+
vAPI.net.registerListeners = function() {
var onBeforeRequest = this.onBeforeRequest;
@@ -611,17 +640,17 @@ vAPI.net.registerListeners = function() {
}
// blocking unwanted pop-ups
else if (e.message.type === 'popup') {
- if (typeof vAPI.tabs.onPopup === 'function') {
- e.message.type = 'main_frame';
- e.message.sourceTabId = vAPI.tabs.getTabId(e.target);
-
- if (vAPI.tabs.onPopup(e.message)) {
- e.message = false;
- return;
- }
+ if (e.message.url === 'about:blank') {
+ vAPI.tabs.expectPopUpFrom = vAPI.tabs.getTabId(e.target);
+ e.message = true;
+ return;
}
- e.message = true;
+ e.message = !vAPI.tabs.onPopup({
+ url: e.message.url,
+ tabId: 0,
+ sourceTabId: vAPI.tabs.getTabId(e.target)
+ });
return;
}
@@ -637,7 +666,7 @@ vAPI.net.registerListeners = function() {
// truthy return value will allow the request,
// except when redirectUrl is present
if (block && typeof block === 'object') {
- if (block.cancel) {
+ if (block.cancel === true) {
e.message = false;
}
else if (e.message.type === 'script'
diff --git a/platform/safari/vapi-client.js b/platform/safari/vapi-client.js
index e0af31ee6..8bfbeb7e6 100644
--- a/platform/safari/vapi-client.js
+++ b/platform/safari/vapi-client.js
@@ -220,7 +220,7 @@ var onBeforeLoad = function(e, details) {
linkHelper.href = details ? details.url : e.url;
- if (!/^https?:/.test(linkHelper.protocol)) {
+ if (!(/^https?:/.test(linkHelper.protocol) || (details && details.type === 'popup'))) {
return;
}
diff --git a/platform/vapi-appinfo.js b/platform/vapi-appinfo.js
deleted file mode 100644
index b2b2cdcf0..000000000
--- a/platform/vapi-appinfo.js
+++ /dev/null
@@ -1,43 +0,0 @@
-/*******************************************************************************
-
- µBlock - a Chromium browser extension to block requests.
- Copyright (C) 2014 The µBlock authors
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see {http://www.gnu.org/licenses/}.
-
- Home: https://github.com/gorhill/uBlock
-*/
-
-// Can be included anywhere if it's needed
-
-/* global self */
-
-/******************************************************************************/
-
-(function(){
-
-'use strict';
-
-/******************************************************************************/
-
-self.vAPI = self.vAPI || {};
-
-self.vAPI.app = {
- name: 'µBlock',
- version: '0.7.2.0'
-};
-
-/******************************************************************************/
-
-})();
\ No newline at end of file
diff --git a/src/js/tab.js b/src/js/tab.js
index 69dff3aa3..3b3a2f791 100644
--- a/src/js/tab.js
+++ b/src/js/tab.js
@@ -80,15 +80,12 @@ vAPI.tabs.onPopup = function(details) {
// Blocked
- // Safari blocks before the pop-up opens, so there is no window to remove.
- // TODO: Can't this test be done within the platform-specific code?
- if ( vAPI.safari ) {
- return true;
- }
-
// It is a popup, block and remove the tab.
µBlock.unbindTabFromPageStats(details.tabId);
vAPI.tabs.remove(details.tabId);
+
+ // for Safari
+ return true;
};
vAPI.tabs.registerListeners();
diff --git a/tools/make-safari.sh b/tools/make-safari.sh
index 5975ccbdb..89f89942a 100644
--- a/tools/make-safari.sh
+++ b/tools/make-safari.sh
@@ -15,8 +15,7 @@ cp -R src/lib $DES/
cp -R src/_locales $DES/
cp src/*.html $DES/
cp src/img/icon_128.png $DES/Icon.png
-cp platform/vapi-appinfo.js $DES/js/
-cp platform/safariextz/*.js $DES/js/
-cp platform/safariextz/Info.plist $DES/
-cp platform/safariextz/Settings.plist $DES/
+cp platform/safari/*.js $DES/js/
+cp platform/safari/Info.plist $DES/
+cp platform/safari/Settings.plist $DES/
echo "*** uBlock.safariextension: Package done."