Skip to content

Commit

Permalink
version 0.4.3
Browse files Browse the repository at this point in the history
  • Loading branch information
belaviyo committed Feb 19, 2020
1 parent ceb90a1 commit ff0913d
Show file tree
Hide file tree
Showing 16 changed files with 271 additions and 232 deletions.
3 changes: 1 addition & 2 deletions config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
/* globals exports */
'use strict';

exports.id = 'com.add0n.native_client';
exports.version = '0.4.2';
exports.version = '0.4.3';

exports.ids = {
chrome: [
Expand Down
5 changes: 2 additions & 3 deletions host.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/* globals require, process */
'use strict';

var config = require('./config.js');
const config = require('./config.js');

// closing node when parent process is killed
process.stdin.resume();
Expand Down Expand Up @@ -62,7 +61,7 @@ function observe(request, push, done) {
}
}
/* message passing */
var nativeMessage = require('./messaging');
const nativeMessage = require('./messaging');
process.stdin
.pipe(new nativeMessage.Input())
.pipe(new nativeMessage.Transform(observe))
Expand Down
4 changes: 3 additions & 1 deletion install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ if [ $isNode -eq 0 ]; then
fi
if [ $isNode -eq 0 ]; then
echo "Installer is using your system NodeJS."
echo
node install.js `which node` $1
else
MACHINE_TYPE=`uname -m`
echo "Installer is using the attached NodeJS"
echo "Installer is using the embedded NodeJS"
echo
if [ ${MACHINE_TYPE} == 'x86_64' ]; then
../node/x64/node install.js --add_node $1
else
Expand Down
112 changes: 53 additions & 59 deletions linux/app/install.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
/* globals require, process */
'use strict';

var fs = require('fs');
var path = require('path');
const fs = require('fs');
const path = require('path');

var share = process.argv.filter(a => a.startsWith('--custom-dir=')).map(a => a.split('=')[1])[0] ||
let share = process.argv.filter(a => a.startsWith('--custom-dir=')).map(a => a.split('=')[1])[0] ||
path.resolve(process.env.HOME, '.config');
if (share[0] === '~') {
share = path.join(process.env.HOME, share.slice(1));
Expand Down Expand Up @@ -42,9 +41,9 @@ function exists(directory, callback) {
one();
}

var {id, ids} = require('./config.js');
var dir = path.join(share, id);
var name = id;
const {id, ids} = require('./config.js');
const dir = path.join(share, id);
const name = id;

function manifest(root, type, callback) {
console.log(' -> Creating a directory at', root);
Expand Down Expand Up @@ -101,61 +100,56 @@ function application(callback) {
});
});
}
function chrome(callback) {
if (ids.chrome.length) {
const loc = path.join(
process.env.HOME,
'.config/google-chrome/NativeMessagingHosts'
);
manifest(loc, 'chrome', callback);
console.error(' -> Chrome Browser is supported');
}
else {
callback();
}
}
function chromium(callback) {
if (ids.chrome.length) {
const loc = path.join(
process.env.HOME,
'.config/chromium/NativeMessagingHosts'
);
manifest(loc, 'chrome', callback);
console.error(' -> Chromium Browser is supported');
}
else {
callback();
}
}
function vivaldi(callback) {
if (ids.chrome.length) {
const loc = path.join(
process.env.HOME,
'.config/vivaldi/NativeMessagingHosts'
);
manifest(loc, 'chrome', callback);
console.error(' -> Vivaldi Browser is supported');
}
else {
callback();
}
async function chrome() {
const run = p => new Promise(resolve => {
if (ids.chrome.length) {
const loc = path.join(process.env.HOME, p);
manifest(loc, 'chrome', resolve);
}
else {
resolve();
}
});

await run('.config/google-chrome/NativeMessagingHosts');
console.error(' -> Chrome Browser is supported');
await run('.config/chromium/NativeMessagingHosts');
console.log(' -> Chromium Browser is supported');
await run('.config/vivaldi/NativeMessagingHosts');
console.log(' -> Vivaldi Browser is supported');
await run('.config/BraveSoftware/Brave-Browser/NativeMessagingHosts');
console.log(' -> Brave Browser is supported');
await run('.config/microsoftedge/NativeMessagingHosts');
console.log(' -> Microsoft Edge Browser is supported');
}
function firefox(callback) {
if (ids.firefox.length) {
const loc = path.join(
process.env.HOME,
'.mozilla/native-messaging-hosts'
);
manifest(loc, 'firefox', callback);
console.error(' -> Firefox Browser is supported');
}
else {
callback();
}

async function firefox() {
const run = p => new Promise(resolve => {
if (ids.firefox.length) {
const loc = path.join(process.env.HOME, p);
manifest(loc, 'firefox', resolve);
}
else {
resolve();
}
});

await run('.mozilla/native-messaging-hosts');
console.log(' -> Firefox Browser is supported');
await run('.waterfox/native-messaging-hosts');
console.log(' -> Waterfox Browser is supported');
await run('.tor-browser/app/Browser/TorBrowser/Data/Browser/.mozilla/native-messaging-hosts');
console.log(' -> Tor Browser is supported');
await run('.thunderbird/native-messaging-hosts');
console.log(' -> Thunderbird Email Client is supported');
}
chrome(() => chromium(() => vivaldi(() => firefox(() => {

(async () => {
await chrome();
await firefox();

application(() => {
console.error(' => Native Host is installed in', dir);
console.error('\n\n>>> Application is ready to use <<<\n\n');
});
}))));
})();
Binary file modified linux/node/x64/node
Binary file not shown.
1 change: 1 addition & 0 deletions linux/node/x86/ReadMe
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
https://unofficial-builds.nodejs.org/download/release/v10.16.3/
Binary file modified linux/node/x86/node
Binary file not shown.
28 changes: 20 additions & 8 deletions linux/uninstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,26 @@ fi
echo "Native Client id is \"${id}\""
echo

echo " .. Removing manifest file for Google Chrome"
rm ~/.config/google-chrome/NativeMessagingHosts/${id}.json
echo " .. Removing manifest file for Chromium"
rm ~/.config/chromium/NativeMessagingHosts/${id}.json
echo " .. Removing manifest file for Mozilla Firefox"
rm ~/.mozilla/native-messaging-hosts/${id}.json
echo " .. Removing executable"
[ -n "$id" ] && rm -r ~/.config/${id}
echo " -> Removing manifest file for Google Chrome"
rm -f ~/.config/google-chrome/NativeMessagingHosts/${id}.json
echo " -> Removing manifest file for Chromium"
rm -f ~/.config/chromium/NativeMessagingHosts/${id}.json
echo " -> Removing manifest file for Vivaldi"
rm -f ~/.config/vivaldi/NativeMessagingHosts/${id}.json
echo " -> Removing manifest file for Brave"
rm -f ~/.config/BraveSoftware/Brave-Browser/NativeMessagingHosts/${id}.json
echo " -> Removing manifest file for Microsoft Edge"
rm -f ~/.config/microsoftedge/NativeMessagingHosts/${id}.json
echo " -> Removing manifest file for Mozilla Firefox"
rm -f ~/.mozilla/native-messaging-hosts/${id}.json
echo " -> Removing manifest file for Waterfox"
rm -f ~/.waterfox/native-messaging-hosts/${id}.json
echo " -> Removing manifest file for Tor"
rm -f ~/.tor-browser/app/Browser/TorBrowser/Data/Browser/.mozilla/native-messaging-hosts/${id}.json
echo " -> Removing manifest file for Thunderbird"
rm -f ~/.thunderbird/native-messaging-hosts/${id}.json
echo " -> Removing executable"
[ -n "$id" ] && rm -f -r ~/.config/${id}

echo
echo ">>> Native Client is removed <<<".
Loading

0 comments on commit ff0913d

Please sign in to comment.