diff --git a/meta/safariextz/Info.plist b/meta/safariextz/Info.plist
deleted file mode 100644
index 50134bc3a..000000000
--- a/meta/safariextz/Info.plist
+++ /dev/null
@@ -1,91 +0,0 @@
-
-
-
-
- Author
- Raymond Hill
- Builder Version
- 534.57.2
- CFBundleDisplayName
- µBlock
- CFBundleIdentifier
- net.gorhill.uBlock
- CFBundleInfoDictionaryVersion
- 6.0
- CFBundleShortVersionString
- 0.7.0.10
- CFBundleVersion
- 1456132
- Chrome
-
- Database Quota
- 52428800
- Global Page
- background.html
- Popovers
-
-
- Filename
- popup.html
- Height
- 310
- Identifier
- popover
- Width
- 180
-
-
- Toolbar Items
-
-
- Identifier
- toolbarItem
- Image
- img/icon16.png
- Label
- µBlock
- Popover
- popover
-
-
-
- Content
-
- Scripts
-
- End
-
- js/contentscript-end.js
-
- Start
-
- js/vapi-client.js
- js/contentscript-start.js
-
-
- Whitelist
-
- http://*/*
- https://*/*
-
-
- Description
- Finally, an efficient blocker. Easy on CPU and memory.
- ExtensionInfoDictionaryVersion
- 1.0
- Permissions
-
- Website Access
-
- Include Secure Pages
-
- Level
- All
-
-
-
- Website
- https://github.com/gorhill/uBlock
-
-
diff --git a/meta/safariextz/Settings.plist b/meta/safariextz/Settings.plist
deleted file mode 100644
index 40cc1ff16..000000000
--- a/meta/safariextz/Settings.plist
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
-
-
-
- DefaultValue
-
- FalseValue
-
- Key
- open_prefs
- Secure
-
- Title
- Click to see the Preferences
- TrueValue
-
- Type
- CheckBox
-
-
-
diff --git a/platform/safari/Info.plist b/platform/safari/Info.plist
new file mode 100644
index 000000000..084209322
--- /dev/null
+++ b/platform/safari/Info.plist
@@ -0,0 +1,91 @@
+
+
+
+
+ Author
+ Raymond Hill
+ Builder Version
+ 534.57.2
+ CFBundleDisplayName
+ µBlock
+ CFBundleIdentifier
+ net.gorhill.uBlock
+ CFBundleInfoDictionaryVersion
+ 6.0
+ CFBundleShortVersionString
+ 0.7.0.11
+ CFBundleVersion
+ 1
+ Chrome
+
+ Database Quota
+ 52428800
+ Global Page
+ background.html
+ Popovers
+
+
+ Filename
+ popup.html
+ Height
+ 310
+ Identifier
+ popover
+ Width
+ 180
+
+
+ Toolbar Items
+
+
+ Identifier
+ toolbarItem
+ Image
+ img/icon16.png
+ Label
+ µBlock
+ Popover
+ popover
+
+
+
+ Content
+
+ Scripts
+
+ End
+
+ js/contentscript-end.js
+
+ Start
+
+ js/vapi-client.js
+ js/contentscript-start.js
+
+
+ Whitelist
+
+ http://*/*
+ https://*/*
+
+
+ Description
+ Finally, an efficient blocker. Easy on CPU and memory.
+ ExtensionInfoDictionaryVersion
+ 1.0
+ Permissions
+
+ Website Access
+
+ Include Secure Pages
+
+ Level
+ All
+
+
+
+ Website
+ https://github.com/gorhill/uBlock
+
+
diff --git a/platform/safari/Settings.plist b/platform/safari/Settings.plist
new file mode 100644
index 000000000..6c80bbb43
--- /dev/null
+++ b/platform/safari/Settings.plist
@@ -0,0 +1,22 @@
+
+
+
+
+
+ DefaultValue
+
+ FalseValue
+
+ Key
+ open_prefs
+ Secure
+
+ Title
+ Click to see the Preferences
+ TrueValue
+
+ Type
+ CheckBox
+
+
+
diff --git a/meta/safariextz/sitepatch-safari.js b/platform/safari/sitepatch-safari.js
similarity index 100%
rename from meta/safariextz/sitepatch-safari.js
rename to platform/safari/sitepatch-safari.js
diff --git a/meta/safariextz/update_safariextz.plist b/platform/safari/update_safariextz.plist
similarity index 90%
rename from meta/safariextz/update_safariextz.plist
rename to platform/safari/update_safariextz.plist
index 0681b05e6..f82911e17 100644
--- a/meta/safariextz/update_safariextz.plist
+++ b/platform/safari/update_safariextz.plist
@@ -10,9 +10,9 @@
Developer Identifier
CFBundleShortVersionString
- 0.7.0.10
+ 0.7.0.11
CFBundleVersion
- 1456132
+ 1
URL
https://.../uBlock.safariextz
diff --git a/meta/safariextz/vapi-background.js b/platform/safari/vapi-background.js
similarity index 95%
rename from meta/safariextz/vapi-background.js
rename to platform/safari/vapi-background.js
index d4a78d6bc..4976eb1df 100644
--- a/meta/safariextz/vapi-background.js
+++ b/platform/safari/vapi-background.js
@@ -132,6 +132,10 @@ vAPI.storage = {
callback();
},
getBytesInUse: function(keys, callback) {
+ if (typeof callback !== 'function') {
+ return;
+ }
+
var key, size = 0;
if (keys === null) {
@@ -230,15 +234,16 @@ vAPI.tabs.get = function(tabId, callback) {
title: tab.title
});
};
-// properties of the details object:
-// url: 'URL', // the address that will be opened
-// tabId: 1, // the tab is used if set, instead of creating a new one
-// index: -1, // undefined: end of the list, -1: following tab, or after index
-// active: false, // opens the tab in background - true and undefined: foreground
-// select: true // if a tab is already opened with that url, then select it instead of opening a new one
/******************************************************************************/
+// properties of the details object:
+// url: 'URL', // the address that will be opened
+// tabId: 1, // the tab is used if set, instead of creating a new one
+// index: -1, // undefined: end of the list, -1: following tab, or after index
+// active: false, // opens the tab in background - true and undefined: foreground
+// select: true // if a tab is already opened with that url, then select it instead of opening a new one
+
vAPI.tabs.open = function(details) {
if (!details.url) {
return null;
@@ -293,13 +298,19 @@ vAPI.tabs.open = function(details) {
/******************************************************************************/
-vAPI.tabs.close = function(tab) {
- if (!(tab instanceof SafariBrowserTab)) {
- tab = this.stack[tab];
+vAPI.tabs.close = function(tabIds) {
+ if (tabIds instanceof SafariBrowserTab) {
+ tabIds = this.getTabId(tabIds);
}
- if (tab) {
- tab.close();
+ if (!Array.isArray(tabIds)) {
+ tabIds = [tabIds];
+ }
+
+ for (var i = 0; i < tabIds.length; i++) {
+ if (this.stack[tabIds[i]]) {
+ this.stack[tabIds[i]].close();
+ }
}
};
@@ -638,7 +649,11 @@ vAPI.net.registerListeners = function() {
return e.message;
};
- safari.application.addEventListener('message', this.onBeforeRequest.callback, true);
+ safari.application.addEventListener(
+ 'message',
+ this.onBeforeRequest.callback,
+ true
+ );
}
};
diff --git a/meta/safariextz/vapi-client.js b/platform/safari/vapi-client.js
similarity index 95%
rename from meta/safariextz/vapi-client.js
rename to platform/safari/vapi-client.js
index 65e40029e..ca4e0b826 100644
--- a/meta/safariextz/vapi-client.js
+++ b/platform/safari/vapi-client.js
@@ -30,7 +30,7 @@
/******************************************************************************/
self.vAPI = self.vAPI || {};
-self.vAPI.safari = true;
+vAPI.safari = true;
/******************************************************************************/
@@ -39,11 +39,15 @@ var messagingConnector = function(response) {
return;
}
+ var channels = vAPI.messaging.channels;
var channel, listener;
if ( response.broadcast === true ) {
- for ( channel in vAPI.messaging.channels ) {
- listener = vAPI.messaging.channels[channel].listener;
+ for ( channel in channels ) {
+ if ( channels.hasOwnProperty(channel) === false ) {
+ continue;
+ }
+ listener = channels[channel].listener;
if ( typeof listener === 'function' ) {
listener(response.msg);
}
@@ -58,7 +62,7 @@ var messagingConnector = function(response) {
}
if ( !listener ) {
- channel = vAPI.messaging.channels[response.portName];
+ channel = channels[response.portName];
listener = channel && channel.listener;
}
@@ -171,9 +175,16 @@ vAPI.messaging = {
/******************************************************************************/
-// content scripts are loaded into extension pages by default, but they shouldn't
+vAPI.canExecuteContentScript = function() {
+ return /^https?:/.test(location.protocol);
+};
-if (location.protocol === "safari-extension:") {
+/******************************************************************************/
+
+// This file can be included into extensin pages,
+// but the following code should run only in content pages.
+
+if (location.protocol === 'safari-extension:') {
return;
}
@@ -358,7 +369,7 @@ var onContextMenu = function(e) {
details.editable = details.tagName === 'textarea' || details.tagName === 'input';
- if ('checked' in e.target) {
+ if (e.target.hasOwnProperty('checked')) {
details.checked = e.target.checked;
}
@@ -366,7 +377,7 @@ var onContextMenu = function(e) {
details.linkUrl = e.target.href;
}
- if ('src' in e.target) {
+ if (e.target.hasOwnProperty('src')) {
details.srcUrl = e.target.src;
if (details.tagName === 'img') {
@@ -394,12 +405,6 @@ if (frameId === 0) {
/******************************************************************************/
-self.vAPI.canExecuteContentScript = function() {
- return /^https?:/.test(location.protocol);
-};
-
-/******************************************************************************/
-
})();
/******************************************************************************/
diff --git a/meta/safariextz/vapi-common.js b/platform/safari/vapi-common.js
similarity index 99%
rename from meta/safariextz/vapi-common.js
rename to platform/safari/vapi-common.js
index 2021d7765..f7f1a6405 100644
--- a/meta/safariextz/vapi-common.js
+++ b/platform/safari/vapi-common.js
@@ -55,7 +55,6 @@ vAPI.download = function(details) {
a.dispatchEvent(new MouseEvent('click'));
return;
}
-
var messager = vAPI.messaging.channel('_download');
messager.send({
what: 'gotoURL',
diff --git a/tools/make-safari.sh b/tools/make-safari.sh
index 6a5eb5226..5975ccbdb 100644
--- a/tools/make-safari.sh
+++ b/tools/make-safari.sh
@@ -16,7 +16,7 @@ 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 meta/safariextz/*.js $DES/js/
-cp meta/safariextz/Info.plist $DES/
-cp meta/safariextz/Settings.plist $DES/
+cp platform/safariextz/*.js $DES/js/
+cp platform/safariextz/Info.plist $DES/
+cp platform/safariextz/Settings.plist $DES/
echo "*** uBlock.safariextension: Package done."