aboutsummaryrefslogtreecommitdiffstats
path: root/src/js
diff options
context:
space:
mode:
authorDeathamns <deathamns@gmail.com>2014-11-09 17:50:58 +0100
committerDeathamns <deathamns@gmail.com>2014-11-09 18:58:46 +0100
commit0d9d285608ac73fa9523475d8e608ce846cf5911 (patch)
treef70afb468bbc99eece361223cc1765d3af900498 /src/js
parent4bf6664d6b28bfab7d1d220a40e54be0ad0ebfe2 (diff)
downloaduBlock-0d9d285608ac73fa9523475d8e608ce846cf5911.zip
uBlock-0d9d285608ac73fa9523475d8e608ce846cf5911.tar.gz
uBlock-0d9d285608ac73fa9523475d8e608ce846cf5911.tar.bz2
Building extension files
Adds possibility to build extension files (Chrome and Safari) from command line. To run from the project directory: python tools/build.py [meta] If the optional `meta` argument is set, then only the manifest and language files are uptated. Without that everything is being built (extension files too) into the `dist/build/version_number` folder. For Chrome there will be two files, a crx, and a .zip file which includes the key.pem private key (so this must not be shared, it's just a bit help for publishing it to the Chrome Web Store). Beside the extension files, update-files are generated too (for self hosting - Safari needs it).
Diffstat (limited to 'src/js')
-rw-r--r--src/js/i18n.js6
-rw-r--r--src/js/vapi-appinfo.js2
-rw-r--r--src/js/vapi-background.js9
-rw-r--r--src/js/vapi-client.js19
-rw-r--r--src/js/vapi-common.js11
-rw-r--r--src/js/xal.js4
6 files changed, 34 insertions, 17 deletions
diff --git a/src/js/i18n.js b/src/js/i18n.js
index ce05041..bee0b96 100644
--- a/src/js/i18n.js
+++ b/src/js/i18n.js
@@ -28,10 +28,10 @@
uDom.onLoad(function() {
uDom('[data-i18n]').forEach(function(elem) {
- elem.html(vAPI.i18n.getMessage(elem.attr('data-i18n')));
+ elem.html(vAPI.i18n(elem.attr('data-i18n')));
});
uDom('[title]').forEach(function(elem) {
- var title = vAPI.i18n.getMessage(elem.attr('title'));
+ var title = vAPI.i18n(elem.attr('title'));
if ( title ) {
elem.attr('title', title);
}
@@ -39,7 +39,7 @@ uDom.onLoad(function() {
uDom('[data-i18n-tip]').forEach(function(elem) {
elem.attr(
'data-tip',
- vAPI.i18n.getMessage(elem.attr('data-i18n-tip')).replace(/<br>/g, '')
+ vAPI.i18n(elem.attr('data-i18n-tip')).replace(/<br>/g, '')
);
});
});
diff --git a/src/js/vapi-appinfo.js b/src/js/vapi-appinfo.js
index 372fc04..2deaeb5 100644
--- a/src/js/vapi-appinfo.js
+++ b/src/js/vapi-appinfo.js
@@ -5,6 +5,6 @@ self.vAPI = self.vAPI || {};
vAPI.app = {
/**/name: 'µBlock',
- /**/version: '0.7.0.9',
+ /**/version: '0.7.0.10',
/**/url: 'https://github.com/gorhill/uBlock',
}; \ No newline at end of file
diff --git a/src/js/vapi-background.js b/src/js/vapi-background.js
index 323505d..0e0ab22 100644
--- a/src/js/vapi-background.js
+++ b/src/js/vapi-background.js
@@ -1,3 +1,4 @@
+// » header
/* global SafariBrowserTab, Services, XPCOMUtils */
// for background page only
@@ -5,8 +6,10 @@
'use strict';
self.vAPI = self.vAPI || {};
+// «
if (self.chrome) {
+ // » crx
var chrome = self.chrome;
vAPI.chrome = true;
@@ -272,7 +275,9 @@ if (self.chrome) {
chrome.contextMenus.remove(this.menuId);
}
};
+ // «
} else if (self.safari) {
+ // » safariextz
vAPI.safari = true;
// addContentScriptFromURL allows whitelisting,
@@ -888,9 +893,13 @@ if (self.chrome) {
this.onContextMenuCommand = null;
}
};
+ // «
}
+// » footer
+
if (!self.chrome) {
self.chrome = { runtime: { lastError: null } };
}
})();
+// «
diff --git a/src/js/vapi-client.js b/src/js/vapi-client.js
index e441292..26bc6d8 100644
--- a/src/js/vapi-client.js
+++ b/src/js/vapi-client.js
@@ -1,3 +1,4 @@
+// » header
/* global addMessageListener, removeMessageListener, sendAsyncMessage */
// for non background pages
@@ -51,8 +52,10 @@ var messagingConnector = function(response) {
var uniqueId = function() {
return parseInt(Math.random() * 1e10, 10).toString(36);
};
+// «
if (self.chrome) {
+ // » crx
vAPI.chrome = true;
vAPI.messaging = {
port: null,
@@ -60,15 +63,14 @@ if (self.chrome) {
listeners: {},
requestId: 0,
connectorId: uniqueId(),
- connector: messagingConnector,
setup: function() {
this.port = chrome.runtime.connect({name: this.connectorId});
- this.port.onMessage.addListener(this.connector);
+ this.port.onMessage.addListener(messagingConnector);
},
close: function() {
if (this.port) {
this.port.disconnect();
- this.port.onMessage.removeListener(this.connector);
+ this.port.onMessage.removeListener(messagingConnector);
this.port = this.channels = this.listeners = this.connectorId = null;
}
},
@@ -105,7 +107,9 @@ if (self.chrome) {
return this.channels[channelName];
}
};
+ // «
} else if (self.safari) {
+ // » safariextz
vAPI.safari = true;
// relevant?
@@ -115,7 +119,6 @@ if (self.chrome) {
listeners: {},
requestId: 0,
connectorId: uniqueId(),
- connector: messagingConnector,
setup: function() {
this._connector = function(msg) {
// messages from the background script are sent to every frame,
@@ -123,7 +126,7 @@ if (self.chrome) {
// what is meant for the current context
if (msg.name === vAPI.messaging.connectorId
|| msg.name === 'broadcast') {
- vAPI.messaging.connector(msg.message);
+ messagingConnector(msg.message);
}
};
safari.self.addEventListener('message', this._connector, false);
@@ -174,7 +177,7 @@ if (self.chrome) {
target: {
page: {
dispatchMessage: function(name, msg) {
- vAPI.messaging.connector(msg);
+ messagingConnector(msg);
}
}
}
@@ -371,6 +374,8 @@ if (self.chrome) {
url: window.location.href,
type: 'main_frame'
});
+ // «
}
-
+// » footer
})();
+// « \ No newline at end of file
diff --git a/src/js/vapi-common.js b/src/js/vapi-common.js
index a44aa74..d8c0b4a 100644
--- a/src/js/vapi-common.js
+++ b/src/js/vapi-common.js
@@ -1,3 +1,4 @@
+// » header
// could be used for background and other extension pages
(function() {
@@ -37,8 +38,10 @@ vAPI.download = function(details) {
messager.close();
}
};
+// «
if (self.chrome) {
+ // » crx
var chrome = self.chrome;
vAPI.getURL = function(path) {
@@ -50,7 +53,9 @@ if (self.chrome) {
};
setScriptDirection(vAPI.i18n('@@ui_locale'));
+ // «
} else if (self.safari) {
+ // » safariextz
vAPI.getURL = function(path) {
return safari.extension.baseURI + path;
};
@@ -119,6 +124,8 @@ if (self.chrome) {
}
});
}
+ // «
}
-
-})(); \ No newline at end of file
+// » footer
+})();
+// « \ No newline at end of file
diff --git a/src/js/xal.js b/src/js/xal.js
index 7781485..6097c54 100644
--- a/src/js/xal.js
+++ b/src/js/xal.js
@@ -58,10 +58,6 @@ exports.restart = function() {
if (vAPI.chrome) {
chrome.runtime.reload();
}
-
- // TODO? for cross-browser solution:
- // window.location.reload();
- // plus close all extension tabs
};
/******************************************************************************/