mirror of
https://github.com/gorhill/uMatrix.git
synced 2024-09-30 00:56:32 +13:00
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).
This commit is contained in:
parent
a39572448d
commit
aebfb15aa2
1 changed files with 12 additions and 7 deletions
|
@ -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
|
||||
})();
|
||||
// «
|
Loading…
Reference in a new issue