From 6d787158fcf1e42699766248bf694f3166c591e3 Mon Sep 17 00:00:00 2001 From: Andy Portmen Date: Tue, 17 Jan 2017 11:30:58 +0330 Subject: [PATCH] version 0.2.1 is ready --- README.md | 24 ++++++++++++++++++++++++ config.js | 4 ++++ host.js | 2 +- install.sh | 8 ++++---- linux/app/install.js | 21 +++++++++++++++------ mac/app/install.js | 22 +++++++++++++++------- windows/app/install.js | 8 ++++---- windows/install.bat | 6 ++++-- 8 files changed, 71 insertions(+), 24 deletions(-) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..0125b5d --- /dev/null +++ b/README.md @@ -0,0 +1,24 @@ +# native-client + +This [NodeJS](https://nodejs.org/) based small client helps the following extensions to communicate with your operation system + +1. Open in Firefox [open Firefox browser with provided URL] +2. Open in IE [open Internet Explorer browser with provided URL] +3. Open in Chrome [open Chrome browser with provided URL] +4. Open in Edge [open Microsoft Edge browser with provided URL] +5. Open in Safari [open Safari browser with provided URL] +6. Open in GIMP photo editor [open GIMP photo editor with provided URL or a temporary local image file (data-url's are being converted to a temporary local files and then GIMP is called to open this file)] +7. Open in VLC media Player [open VLC media Player with provided URL] +8. Media Converter and Muxer [Download FFmpeg media converter, Open FFmpeg, Export media files to a temporary directory then call FFmpeg] + +You can find up-to-date list as well as IDs here: https://github.com/andy-portmen/native-client/blob/master/config.js + +Notes: + +1. On Linux and Mac, installer script only copies node executable if it is not already defined in the PATH enviroment. Please make sure you have an up-to-date version of NodeJS +2. On Linux and Mac, you can define custom root directory by adding `--custom-dir=` to the installer script + Example: `./install.sh --custom-dir=~/Desktop/` +3. Removing the native client [Linux and Mac]: As of version 0.2.1, the installer prints all the directries it creates or inserts scripts in. Basically on Linux and Mac, two JSON files are inserted to predefined directories and a root directory is created which contains all the files. To remove the program simply delete the root directory and delete the two generated manifest JSON files. Path to all these files will be printed during installation +4. Removing the native client [windows]: On Windows OS, a directory is created in "Program Files" and all the files are inserted in this directory. To remove the program, simply delete this directory. Also note that two registry entries are also added so that Chrome, Opera, and Firefox browsers can find the actual executable. Path to these registry entries are also printed during installation +5. If you don't remember where the files are, simply run the installer one more time. It just overwrites all the files. +6. For the installer to be able to copy manifest files and to create the root directory, it needs administration (sudo) permission. If you are not comfortable to allow this permission, you can manually copy all the files diff --git a/config.js b/config.js index cd1f318..6f46f5f 100644 --- a/config.js +++ b/config.js @@ -14,9 +14,13 @@ exports.ids = { 'fabccabfpmdadbhljpcmcbmepepfllnb', // Media Converter (Opera) 'jgpghknlbaljigdhcjimjnkkjniiipmm', // Open in GIMP (Chrome) 'cmjahocdpafkodabbojjaebogoigcipj', // Open in GIMP (Opera) + 'bifmfjgpgndemajpeeoiopbeilbaifdo', // External Application Button (Chrome) + 'enemdfoackoekaedijjmjlckkleokhih', // External Application Button (Opera) + 'ihpiinojhnfhpdmmacgmpoonphhimkaj', // Open in VLC (Chrome) ], firefox: [ '{5610edea-88c1-4370-b93d-86aa131971d1}', // Open in IE '{0ff128a1-c286-4e73-bffa-9ae879b244d5}', // Media Converter + '{65b77238-bb05-470a-a445-ec0efe1d66c4}', // External Application Button ] }; diff --git a/host.js b/host.js index 4e0688d..ca5a92b 100755 --- a/host.js +++ b/host.js @@ -20,7 +20,7 @@ var https = lazyRequire('./follow-redirects').https; var server, files = []; var config = { - version: '0.1.7' + version: '0.2.1' }; // closing node when parent process is killed process.stdin.resume(); diff --git a/install.sh b/install.sh index bee374a..05d7a10 100755 --- a/install.sh +++ b/install.sh @@ -3,10 +3,10 @@ cd ./app if type node 2>/dev/null; then - echo Installer is using your system node.js - sudo node install.js `which node` + echo Installer is using your system NodeJS; Please make sure your NodeJS is up-to-date. + sudo node install.js `which node` $1 else - echo Installer is using the attached node.js - sudo ../node install.js --add_node + echo Installer is using the attached NodeJS + sudo ../node install.js --add_node $1 fi diff --git a/linux/app/install.js b/linux/app/install.js index 7e19584..0740d25 100644 --- a/linux/app/install.js +++ b/linux/app/install.js @@ -3,6 +3,13 @@ var fs = require('fs'); var path = require('path'); +var share = process.argv.filter(a => a.startsWith('--custom-dir=')).map(a => a.split('=')[1])[0] || '/usr/share'; +if (share[0] === '~') { + share = path.join(process.env.HOME, share.slice(1)); +} +share = path.resolve(share); +console.log(' -> Root directory is', share); + function exists (directory, callback) { let root = '/'; let dirs = directory.split('/'); @@ -33,11 +40,12 @@ function exists (directory, callback) { one(); } -var dir = path.join('/usr/share', 'com.add0n.node'); +var dir = path.join(share, 'com.add0n.node'); var name = 'com.add0n.node'; var ids = require('./config.js').ids; function manifest (root, type, callback) { + console.log(' -> Creating a directory at', root); exists(root, (e) => { if (e) { throw e; @@ -65,11 +73,12 @@ function manifest (root, type, callback) { }); } function application (callback) { + console.log(' -> Creating a directory at', dir); exists(dir, (e) => { if (e) { throw e; } - let isNode = process.argv[2] !== '--add_node'; + let isNode = process.argv.filter(a => a === '--add_node').length; let run = isNode ? `#!/bin/bash\n${process.argv[2]} host.js` : '#!/bin/bash\n./node host.js'; fs.writeFile(path.join(dir, 'run.sh'), run, (e) => { if (e) { @@ -90,7 +99,7 @@ function application (callback) { function chrome (callback) { if (ids.chrome.length) { manifest('/etc/opt/chrome/native-messaging-hosts', 'chrome', callback); - console.error('Chrome Browser is supported'); + console.error(' -> Chrome Browser is supported'); } else { callback(); @@ -99,7 +108,7 @@ function chrome (callback) { function firefox (callback) { if (ids.firefox.length) { manifest('/usr/lib/mozilla/native-messaging-hosts', 'firefox', callback); - console.error('Firefox Browser is supported'); + console.error(' -> Firefox Browser is supported'); } else { callback(); @@ -107,7 +116,7 @@ function firefox (callback) { } chrome(() => firefox(() => { application(() => { - console.error('Native Host is installed in', dir); - console.error('>> Application is ready to use <<'); + console.error(' => Native Host is installed in', dir); + console.error('\n\n>>> Application is ready to use <<<\n\n'); }); })); diff --git a/mac/app/install.js b/mac/app/install.js index fb1bb80..ec4ec03 100644 --- a/mac/app/install.js +++ b/mac/app/install.js @@ -3,6 +3,13 @@ var fs = require('fs'); var path = require('path'); +var share = process.argv.filter(a => a.startsWith('--custom-dir=')).map(a => a.split('=')[1])[0] || '/usr/share'; +if (share[0] === '~') { + share = path.join(process.env.HOME, share.slice(1)); +} +share = path.resolve(share); +console.log(' -> Root directory is', share); + function exists (directory, callback) { let root = '/'; let dirs = directory.split('/'); @@ -33,11 +40,12 @@ function exists (directory, callback) { one(); } -var dir = path.join('/usr/share', 'com.add0n.node'); +var dir = path.join(share, 'com.add0n.node'); var name = 'com.add0n.node'; var ids = require('./config.js').ids; function manifest (root, type, callback) { + console.log(' -> Creating a directory at', root); exists(root, (e) => { if (e) { throw e; @@ -62,17 +70,17 @@ function manifest (root, type, callback) { } callback(); }); - }); } function application (callback) { + console.log(' -> Creating a directory at', dir); exists(dir, (e) => { if (e) { throw e; } - let isNode = process.argv[2] !== '--add_node'; + let isNode = process.argv.filter(a => a === '--add_node').length; let run = isNode ? `#!/bin/bash\n${process.argv[2]} host.js` : '#!/bin/bash\n./node host.js'; fs.writeFile(path.join(dir, 'run.sh'), run, (e) => { if (e) { @@ -95,7 +103,7 @@ function application (callback) { function chrome (callback) { if (ids.chrome.length) { manifest('/Library/Google/Chrome/NativeMessagingHosts', 'chrome', callback); - console.error('Chrome Browser is supported'); + console.error(' -> Chrome Browser is supported'); } else { callback(); @@ -104,7 +112,7 @@ function chrome (callback) { function firefox (callback) { if (ids.firefox.length) { manifest('/Library/Application Support/Mozilla/NativeMessagingHosts', 'firefox', callback); - console.error('Firefox Browser is supported'); + console.error(' -> Firefox Browser is supported'); } else { callback(); @@ -112,7 +120,7 @@ function firefox (callback) { } chrome(() => firefox(() => { application(() => { - console.error('Native Host is installed in', dir); - console.error('>> Application is ready to use <<'); + console.error(' -> Native Host is installed in', dir); + console.error('\n\n>>> Application is ready to use <<<\n\n'); }); })); diff --git a/windows/app/install.js b/windows/app/install.js index ce196a9..51e108f 100644 --- a/windows/app/install.js +++ b/windows/app/install.js @@ -63,7 +63,7 @@ function application (callback) { function chrome (callback) { if (ids.chrome.length) { manifest('chrome', callback); - console.error('Chrome Browser is supported'); + console.error('.. Chrome Browser is supported'); } else { callback(); @@ -72,7 +72,7 @@ function chrome (callback) { function firefox (callback) { if (ids.firefox.length) { manifest('firefox', callback); - console.error('Firefox Browser is supported'); + console.error('.. Firefox Browser is supported'); } else { callback(); @@ -80,7 +80,7 @@ function firefox (callback) { } chrome(() => firefox(() => { application(() => { - console.error('Native Host is installed in', dir); - console.error('>> Application is ready to use <<'); + console.error('.. Native Host is installed in', dir); + console.error('\n\n>>> Application is ready to use <<<\n\n'); }); })); diff --git a/windows/install.bat b/windows/install.bat index 70c7d03..ca65b43 100644 --- a/windows/install.bat +++ b/windows/install.bat @@ -23,10 +23,12 @@ exit /b :run -echo Writting to Chrome Registry +echo .. Writting to Chrome Registry +echo .. Key: HKCU\Software\Google\Chrome\NativeMessagingHosts\com.add0n.node REG ADD "HKCU\Software\Google\Chrome\NativeMessagingHosts\com.add0n.node" /ve /t REG_SZ /d "%ProgramFiles%\com.add0n.node\manifest-chrome.json" /f -echo Writting to Firefox +echo .. Writting to Firefox Registry +echo .. Key: HKEY_LOCAL_MACHINE\SOFTWARE\Mozilla\NativeMessagingHosts\com.add0n.node for %%f in ("%PROGRAMFILES%") do SET SHORT_PATH=%%~sf REG ADD "HKEY_LOCAL_MACHINE\SOFTWARE\Mozilla\NativeMessagingHosts\com.add0n.node" /ve /t REG_SZ /d "%SHORT_PATH%\com.add0n.node\manifest-firefox.json" /f