diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..237b68f --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,72 @@ +# This is a basic workflow to help you get started with Actions + +name: CI + +# Controls when the workflow will run +on: + push: + # Sequence of patterns matched against refs/tags + tags: + - '*' # Push events to matching v*, i.e. v1.0, v20.15.10 + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + # This workflow contains a single job called "build" + build: + # The type of runner that the job will run on + runs-on: ubuntu-latest + + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - uses: actions/checkout@v2 + + # Runs a set of commands using the runners shell + - name: Run a multi-line script + run: | + cd linux + zip ../linux.zip -9 -r * -x "*.DS_Store" + cd ../mac + zip ../mac.zip -9 -r * -x "*.DS_Store" + cd ../windows + zip ../windows.zip -9 -r * -x "*.DS_Store" + + - name: Create Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref }} + release_name: Release ${{ github.ref }} + draft: false + prerelease: true + + - name: Upload release asset + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./windows.zip + asset_name: windows.zip + asset_content_type: application/zip + - name: Upload release asset + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./linux.zip + asset_name: linux.zip + asset_content_type: application/zip + + - name: Upload release asset + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./mac.zip + asset_name: mac.zip + asset_content_type: application/zip diff --git a/.travis.yml b/.travis.yml index 91d672e..a62b8fd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,7 @@ deploy: provider: releases prerelease: true api_key: - secure: WLscrSf1ad9rEmZodg+tnqVo1IBwI5zAuaulC/bojiYmAR9pysFryas6SyGjgFCK9DKbFiaPUZXOWAT9q9uSgsPkWEARqE69BpXiDo4PLX0BVRhXd5C5Z0Neu6f03Zgx9lxY9/CalR3WF+qqrRSouUa2KveyMA1ofv6I+Q410do4qIbVWR5bY9RTU7SukdOQz1Nq4JhOHBNYEGSZEeu2/7kM8g3GJesSstOQaTSvOWSAQKeyj/aD63LfTNAd1zW577vyEjtXgz0xIvafot3WX88jarEJlLwNWciifssco6z1OCOOZ67unygmBiM62h35ism8qt2OX1S239my1L7kaoCNSPwbQ0GvP9foL9UkXl5zfIxUO6ZnkddouC+p5pI7DBSfJ9dJP3lToNJNei8jBa1xeLWByP6G82A5hKKrWBJEj4T2nXQUD5OAhy0cie0qeYHCA4bed4YMtpk3gHPXBkfhCfiq0qj9BOkPl+B0f0g1b6BGBvxfauphURH2QTqwckativGR4jIGipCHJdGA8WihRtHhoQgwppvlFiPsCJF/WaK2eTXpHAiIEZHNo28y3/frl1CBnpM5pFOfXJd2zk0BKQDyMR/0lcOXPrpaZyUt7lpkoVmCsJjIo+/Uf/fCt7vujol5b2YE4/MaedzJXhnXv3FdtyTot4A9FVOLUT4= + secure: jHB0IfT4ayiY01SNtSbsCAQd7O7qVOzBFW045qWIBeg4Ru+fcDEiEOe6fq1dPBQodrjfti5cKJyoJDpZ9EwPh5ZrANwj9B+IltOaJapR0wSX5vDlYVMBZuMR118JBfxxosw8SxQlVY9YNNRMKSxa75Ud4TkkWSzFOYvHhN8DdJYzBbFZW8LfubIpxenySkTtaBzhwmPqoVvjbq18Dp40FbkBFC40lfFe1UlGN+LQt3PjE7Gxg1yWzoWRL5eFbetdd+VBH4SVTiu/LvVZ8hhk2f3A72CaomiyPKQbzdt+/4skz9pEJZFdb3JvxaO8f0h5X8lS112/u+2qdT6xaAkYPvSipBdOypaLoG1aKgFuVseovsLn1/N8PqAWKzscmd1bf0USKxBkFw1yrvZFFxvmm2nZ8rUzCWrt7ISMvStO//4/YzQUzE1Lm7Z31qji9L0Uc8Xvg356NldNKLpelWJrsae8H5WIukDOdeE7twJ9RYdJ1M6+0jOzR//VMg5pTW0hNOQFDMy9IoAiqNqyUh0bKjf6MS5+/5QJsvzJip+rkuZnVMGxCMlZBT3gfZJSHRXYEIa2DR1p8g7+WBi6yUYSiF6pSjRdmnegnCcfXHpNzSYvdKFAJt5ea911iFtjYb26i4zMuKge3wj+xpSr6RJ/CyhiQudspipJF6gkE2t7sgM= file: - windows.zip - linux.zip diff --git a/COPYING b/COPYING new file mode 100644 index 0000000..a612ad9 --- /dev/null +++ b/COPYING @@ -0,0 +1,373 @@ +Mozilla Public License Version 2.0 +================================== + +1. Definitions +-------------- + +1.1. "Contributor" + means each individual or legal entity that creates, contributes to + the creation of, or owns Covered Software. + +1.2. "Contributor Version" + means the combination of the Contributions of others (if any) used + by a Contributor and that particular Contributor's Contribution. + +1.3. "Contribution" + means Covered Software of a particular Contributor. + +1.4. "Covered Software" + means Source Code Form to which the initial Contributor has attached + the notice in Exhibit A, the Executable Form of such Source Code + Form, and Modifications of such Source Code Form, in each case + including portions thereof. + +1.5. "Incompatible With Secondary Licenses" + means + + (a) that the initial Contributor has attached the notice described + in Exhibit B to the Covered Software; or + + (b) that the Covered Software was made available under the terms of + version 1.1 or earlier of the License, but not also under the + terms of a Secondary License. + +1.6. "Executable Form" + means any form of the work other than Source Code Form. + +1.7. "Larger Work" + means a work that combines Covered Software with other material, in + a separate file or files, that is not Covered Software. + +1.8. "License" + means this document. + +1.9. "Licensable" + means having the right to grant, to the maximum extent possible, + whether at the time of the initial grant or subsequently, any and + all of the rights conveyed by this License. + +1.10. "Modifications" + means any of the following: + + (a) any file in Source Code Form that results from an addition to, + deletion from, or modification of the contents of Covered + Software; or + + (b) any new file in Source Code Form that contains any Covered + Software. + +1.11. "Patent Claims" of a Contributor + means any patent claim(s), including without limitation, method, + process, and apparatus claims, in any patent Licensable by such + Contributor that would be infringed, but for the grant of the + License, by the making, using, selling, offering for sale, having + made, import, or transfer of either its Contributions or its + Contributor Version. + +1.12. "Secondary License" + means either the GNU General Public License, Version 2.0, the GNU + Lesser General Public License, Version 2.1, the GNU Affero General + Public License, Version 3.0, or any later versions of those + licenses. + +1.13. "Source Code Form" + means the form of the work preferred for making modifications. + +1.14. "You" (or "Your") + means an individual or a legal entity exercising rights under this + License. For legal entities, "You" includes any entity that + controls, is controlled by, or is under common control with You. For + purposes of this definition, "control" means (a) the power, direct + or indirect, to cause the direction or management of such entity, + whether by contract or otherwise, or (b) ownership of more than + fifty percent (50%) of the outstanding shares or beneficial + ownership of such entity. + +2. License Grants and Conditions +-------------------------------- + +2.1. Grants + +Each Contributor hereby grants You a world-wide, royalty-free, +non-exclusive license: + +(a) under intellectual property rights (other than patent or trademark) + Licensable by such Contributor to use, reproduce, make available, + modify, display, perform, distribute, and otherwise exploit its + Contributions, either on an unmodified basis, with Modifications, or + as part of a Larger Work; and + +(b) under Patent Claims of such Contributor to make, use, sell, offer + for sale, have made, import, and otherwise transfer either its + Contributions or its Contributor Version. + +2.2. Effective Date + +The licenses granted in Section 2.1 with respect to any Contribution +become effective for each Contribution on the date the Contributor first +distributes such Contribution. + +2.3. Limitations on Grant Scope + +The licenses granted in this Section 2 are the only rights granted under +this License. No additional rights or licenses will be implied from the +distribution or licensing of Covered Software under this License. +Notwithstanding Section 2.1(b) above, no patent license is granted by a +Contributor: + +(a) for any code that a Contributor has removed from Covered Software; + or + +(b) for infringements caused by: (i) Your and any other third party's + modifications of Covered Software, or (ii) the combination of its + Contributions with other software (except as part of its Contributor + Version); or + +(c) under Patent Claims infringed by Covered Software in the absence of + its Contributions. + +This License does not grant any rights in the trademarks, service marks, +or logos of any Contributor (except as may be necessary to comply with +the notice requirements in Section 3.4). + +2.4. Subsequent Licenses + +No Contributor makes additional grants as a result of Your choice to +distribute the Covered Software under a subsequent version of this +License (see Section 10.2) or under the terms of a Secondary License (if +permitted under the terms of Section 3.3). + +2.5. Representation + +Each Contributor represents that the Contributor believes its +Contributions are its original creation(s) or it has sufficient rights +to grant the rights to its Contributions conveyed by this License. + +2.6. Fair Use + +This License is not intended to limit any rights You have under +applicable copyright doctrines of fair use, fair dealing, or other +equivalents. + +2.7. Conditions + +Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted +in Section 2.1. + +3. Responsibilities +------------------- + +3.1. Distribution of Source Form + +All distribution of Covered Software in Source Code Form, including any +Modifications that You create or to which You contribute, must be under +the terms of this License. You must inform recipients that the Source +Code Form of the Covered Software is governed by the terms of this +License, and how they can obtain a copy of this License. You may not +attempt to alter or restrict the recipients' rights in the Source Code +Form. + +3.2. Distribution of Executable Form + +If You distribute Covered Software in Executable Form then: + +(a) such Covered Software must also be made available in Source Code + Form, as described in Section 3.1, and You must inform recipients of + the Executable Form how they can obtain a copy of such Source Code + Form by reasonable means in a timely manner, at a charge no more + than the cost of distribution to the recipient; and + +(b) You may distribute such Executable Form under the terms of this + License, or sublicense it under different terms, provided that the + license for the Executable Form does not attempt to limit or alter + the recipients' rights in the Source Code Form under this License. + +3.3. Distribution of a Larger Work + +You may create and distribute a Larger Work under terms of Your choice, +provided that You also comply with the requirements of this License for +the Covered Software. If the Larger Work is a combination of Covered +Software with a work governed by one or more Secondary Licenses, and the +Covered Software is not Incompatible With Secondary Licenses, this +License permits You to additionally distribute such Covered Software +under the terms of such Secondary License(s), so that the recipient of +the Larger Work may, at their option, further distribute the Covered +Software under the terms of either this License or such Secondary +License(s). + +3.4. Notices + +You may not remove or alter the substance of any license notices +(including copyright notices, patent notices, disclaimers of warranty, +or limitations of liability) contained within the Source Code Form of +the Covered Software, except that You may alter any license notices to +the extent required to remedy known factual inaccuracies. + +3.5. Application of Additional Terms + +You may choose to offer, and to charge a fee for, warranty, support, +indemnity or liability obligations to one or more recipients of Covered +Software. However, You may do so only on Your own behalf, and not on +behalf of any Contributor. You must make it absolutely clear that any +such warranty, support, indemnity, or liability obligation is offered by +You alone, and You hereby agree to indemnify every Contributor for any +liability incurred by such Contributor as a result of warranty, support, +indemnity or liability terms You offer. You may include additional +disclaimers of warranty and limitations of liability specific to any +jurisdiction. + +4. Inability to Comply Due to Statute or Regulation +--------------------------------------------------- + +If it is impossible for You to comply with any of the terms of this +License with respect to some or all of the Covered Software due to +statute, judicial order, or regulation then You must: (a) comply with +the terms of this License to the maximum extent possible; and (b) +describe the limitations and the code they affect. Such description must +be placed in a text file included with all distributions of the Covered +Software under this License. Except to the extent prohibited by statute +or regulation, such description must be sufficiently detailed for a +recipient of ordinary skill to be able to understand it. + +5. Termination +-------------- + +5.1. The rights granted under this License will terminate automatically +if You fail to comply with any of its terms. However, if You become +compliant, then the rights granted under this License from a particular +Contributor are reinstated (a) provisionally, unless and until such +Contributor explicitly and finally terminates Your grants, and (b) on an +ongoing basis, if such Contributor fails to notify You of the +non-compliance by some reasonable means prior to 60 days after You have +come back into compliance. Moreover, Your grants from a particular +Contributor are reinstated on an ongoing basis if such Contributor +notifies You of the non-compliance by some reasonable means, this is the +first time You have received notice of non-compliance with this License +from such Contributor, and You become compliant prior to 30 days after +Your receipt of the notice. + +5.2. If You initiate litigation against any entity by asserting a patent +infringement claim (excluding declaratory judgment actions, +counter-claims, and cross-claims) alleging that a Contributor Version +directly or indirectly infringes any patent, then the rights granted to +You by any and all Contributors for the Covered Software under Section +2.1 of this License shall terminate. + +5.3. In the event of termination under Sections 5.1 or 5.2 above, all +end user license agreements (excluding distributors and resellers) which +have been validly granted by You or Your distributors under this License +prior to termination shall survive termination. + +************************************************************************ +* * +* 6. Disclaimer of Warranty * +* ------------------------- * +* * +* Covered Software is provided under this License on an "as is" * +* basis, without warranty of any kind, either expressed, implied, or * +* statutory, including, without limitation, warranties that the * +* Covered Software is free of defects, merchantable, fit for a * +* particular purpose or non-infringing. The entire risk as to the * +* quality and performance of the Covered Software is with You. * +* Should any Covered Software prove defective in any respect, You * +* (not any Contributor) assume the cost of any necessary servicing, * +* repair, or correction. This disclaimer of warranty constitutes an * +* essential part of this License. No use of any Covered Software is * +* authorized under this License except under this disclaimer. * +* * +************************************************************************ + +************************************************************************ +* * +* 7. Limitation of Liability * +* -------------------------- * +* * +* Under no circumstances and under no legal theory, whether tort * +* (including negligence), contract, or otherwise, shall any * +* Contributor, or anyone who distributes Covered Software as * +* permitted above, be liable to You for any direct, indirect, * +* special, incidental, or consequential damages of any character * +* including, without limitation, damages for lost profits, loss of * +* goodwill, work stoppage, computer failure or malfunction, or any * +* and all other commercial damages or losses, even if such party * +* shall have been informed of the possibility of such damages. This * +* limitation of liability shall not apply to liability for death or * +* personal injury resulting from such party's negligence to the * +* extent applicable law prohibits such limitation. Some * +* jurisdictions do not allow the exclusion or limitation of * +* incidental or consequential damages, so this exclusion and * +* limitation may not apply to You. * +* * +************************************************************************ + +8. Litigation +------------- + +Any litigation relating to this License may be brought only in the +courts of a jurisdiction where the defendant maintains its principal +place of business and such litigation shall be governed by laws of that +jurisdiction, without reference to its conflict-of-law provisions. +Nothing in this Section shall prevent a party's ability to bring +cross-claims or counter-claims. + +9. Miscellaneous +---------------- + +This License represents the complete agreement concerning the subject +matter hereof. If any provision of this License is held to be +unenforceable, such provision shall be reformed only to the extent +necessary to make it enforceable. Any law or regulation which provides +that the language of a contract shall be construed against the drafter +shall not be used to construe this License against a Contributor. + +10. Versions of the License +--------------------------- + +10.1. New Versions + +Mozilla Foundation is the license steward. Except as provided in Section +10.3, no one other than the license steward has the right to modify or +publish new versions of this License. Each version will be given a +distinguishing version number. + +10.2. Effect of New Versions + +You may distribute the Covered Software under the terms of the version +of the License under which You originally received the Covered Software, +or under the terms of any subsequent version published by the license +steward. + +10.3. Modified Versions + +If you create software not governed by this License, and you want to +create a new license for such software, you may create and use a +modified version of this License if you rename the license and remove +any references to the name of the license steward (except to note that +such modified license differs from this License). + +10.4. Distributing Source Code Form that is Incompatible With Secondary +Licenses + +If You choose to distribute Source Code Form that is Incompatible With +Secondary Licenses under the terms of this version of the License, the +notice described in Exhibit B of this License must be attached. + +Exhibit A - Source Code Form License Notice +------------------------------------------- + + This Source Code Form is subject to the terms of the Mozilla Public + License, v. 2.0. If a copy of the MPL was not distributed with this + file, You can obtain one at http://mozilla.org/MPL/2.0/. + +If it is not possible or desirable to put the notice in a particular +file, then You may include the notice in a location (such as a LICENSE +file in a relevant directory) where a recipient would be likely to look +for such a notice. + +You may add additional accurate notices of copyright ownership. + +Exhibit B - "Incompatible With Secondary Licenses" Notice +--------------------------------------------------------- + + This Source Code Form is "Incompatible With Secondary Licenses", as + defined by the Mozilla Public License, v. 2.0. diff --git a/config.js b/config.js index 71fb615..8f43941 100644 --- a/config.js +++ b/config.js @@ -1,14 +1,51 @@ 'use strict'; -exports.id = 'com.add0n.stylus'; -exports.version = '0.1.4'; +exports.id = 'com.add0n.native_client'; +exports.version = '0.4.7'; exports.ids = { chrome: [ - 'mhjehpjceoajlmldfbelpnbapmcnabfe', // Stylus External Editor Integration (Chrome) - 'djlnckfpakjlpfddhboajjmaeljfaacn', // Stylus External Editor Integration (Opera) + 'hfckgfbhdacemicpjljhfbjmkiggeche', // Send to VLC (Chrome) + 'lgbipmmmnjifkiiikaffhceflifbmhib', // Download with IDM (Chrome) + 'jlodlegnpjplclncjkgolcmdhjmlokna', // Download with FDM (Chrome) + 'jfpmbokkdeapjommajdfmmheiiakdlgo', // Download with JDownloader (Chrome) + 'hlbdmmifbcfpccdnoknhdfcifiglaihb', // Download with DAP (Chrome) + 'eiejadjdcchfommckmikpcdnihljbpai', // Edit with Sublime Text (Chrome) + 'gpmjpkmohjgaimfhebdjebpgdnpcadji', // Edit with Notepad++ (Chrome) + + 'hgadfjhoalnaidfdoilgeimnolhcodbc', // Send to VLC (Opera) + 'ngaohleapbfjleillajbginbiaokmncm', // Send to MPC (Opera) + 'kalnbllmkdiidgakcakkoecaahkpakmj', // Send to MPlayer (Opera) + 'kajaikkhnmegmfnlifeklklaienhdekb', // Download with IDM (Opera) + 'iidhcgjgmjodnfbghbgpdnhiajbmgcjo', // Download with FDM (Opera) + 'jjbbcngfknmgdlekfofhaagmogeifbpc', // Download with JDownloader (Opera) + 'ekeecmblpnobdaijmfkcfcnofopooipg', // Download with DAP (Opera) + 'ilonanfdcnaljoedndpfeflllibalflj', // Download with JDownloader (Edge) + 'cmddfbnhpokddncdalabdlmdckcdmboh', // Download with Wget (Opera) + 'gecfhmlaldelfoeahjahajoooenmnlnd', // Download with FlashGet (Opera) + 'eadfknilcdakacgehgfoedimdghaedgi', // Download with FlashGet (Opera) + 'odbhmaaphiednnbgfionolmpkdplpilc', // Edit with Sublime Text (Opera) + 'hfgnckeamhbkolmfeaieemklhejdcmai', // Edit with Notepad++ (Opera) + 'dbghnkdojpkebjbddhhjfjgapoolnikh', // Send to MPV (Opera) + 'ajcbbbkgmbinpbkllamhphpgpgdabnhf', // Edit with VIM (Opera) + + 'iiekfngbnhgiecdjekibkbkaecdneobh', // Edit with Sublime Text (Edge) + 'bihikkbcagnajdoncmjebpalfhecpjnb', // Download with IDM (Edge) ], firefox: [ - '95fce6c2e847856344b2156491239d95f56c7fc1@temporary-addon', // Stylus External Editor Integration + '{3e0ac434-26e0-4c03-b757-3078486800c3}', // Send to VLC + '{cee1ccee-5508-4927-a929-9a557e63bbc8}', // Send to MPC + '{ccad95df-add6-4d8a-aa5c-cdc384075bab}', // Send to MPV + '{c7636e52-8aba-4717-9652-01922ee61eb3}', // Send to MPlayer media player + '{d1646fcf-76ad-49c5-b8b2-e496e9b71189}', // Download with IDM + '{cfd8df21-e05f-46e9-8ea1-af5e5177d492}', // Download with DAP + '{1fb1ffdc-b95d-451e-be52-7303adf9a0d3}', // Download with FDM + '{533953f8-ffb6-421c-af1a-5a02a792ab51}', // Download with Wget + '{48f5395d-5c00-41cd-9a5e-fd2f8d9b74c2}', // Download with FlashGet + '{03e07985-30b0-4ae0-8b3e-0c7519b9bdf6}', // Download with JDownloader + '{708bb4c5-336d-4a30-9126-8bf5d773bb41}', // Download with aria2 + '{5510b212-951a-439c-ae73-b1ebbc68055f}', // Edit with Sublime Text + '{f91bc9ee-ae11-4850-8e6b-ed4b0262ce3b}', // Edit with Notepad++ + '{dc393f22-0d98-44d4-8a2c-9dd72208e9f7}', // Edit with VIM ] }; diff --git a/host.js b/host.js index 18d2999..3548ca4 100755 --- a/host.js +++ b/host.js @@ -1,17 +1,18 @@ 'use strict'; -var config = require('./config.js'); +const config = require('./config.js'); // closing node when parent process is killed process.stdin.resume(); process.stdin.on('end', () => process.exit()); -function observe (request, push, done) { +function observe(request, push, done) { let close; const exception = e => { push({ + code: -1, type: 'exception', - error: e.message + error: e.stack }); close(); }; @@ -42,9 +43,10 @@ function observe (request, push, done) { env: process.env, push, close, + setTimeout, args: request.args, // only allow internal modules that extension already requested permission for - require: (name) => (request.permissions || []).indexOf(name) === -1 ? null : require(name) + require: name => (request.permissions || []).indexOf(name) === -1 ? null : require(name) }; const script = new vm.Script(request.script); const context = new vm.createContext(sandbox); @@ -59,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)) diff --git a/install.sh b/install.sh index b35c258..6f26f52 100755 --- a/install.sh +++ b/install.sh @@ -1,13 +1,23 @@ -#!/bin/bash +#!/usr/bin/env bash -cd ./app +cd "$(dirname "$0")/app" -if type node 2>/dev/null; then - echo "Installer is using your system NodeJS; Please make sure your NodeJS is up-to-date." +which node 2>/dev/null +isNode=$? +echo NodeJS status = $isNode + +if [ $isNode -eq 0 ]; then + node -e "process.exit(Number(process.version.substr(1).split('.')[0]) > 5 ? 0 : 1)" + isNode=$? +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 diff --git a/linux/app/install.js b/linux/app/install.js index f4e6786..94a0d7d 100644 --- a/linux/app/install.js +++ b/linux/app/install.js @@ -1,26 +1,27 @@ '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] || process.env.HOME; +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)); } share = path.resolve(share); console.log(' -> Root directory is', share); -function exists (directory, callback) { +function exists(directory, callback) { let root = '/'; - let dirs = directory.split('/'); - function one () { + const dirs = directory.split('/'); + function one() { root = path.join(root, dirs.shift()); - fs.stat(root, (e) => { + fs.stat(root, e => { if (!e && dirs.length) { one(); } else if (e && e.code === 'ENOENT') { - fs.mkdir(root, (e) => { + fs.mkdir(root, e => { if (e) { callback(e); } @@ -40,13 +41,13 @@ 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) { +function manifest(root, type, callback) { console.log(' -> Creating a directory at', root); - exists(root, (e) => { + exists(root, e => { if (e) { throw e; } @@ -63,85 +64,92 @@ function manifest (root, type, callback) { "path": "${path.join(dir, 'run.sh')}", "type": "stdio", ${origins} - }`, (e) => { + }`, e => { if (e) { throw e; } callback(); }); - }); } -function application (callback) { +function application(callback) { console.log(' -> Creating a directory at', dir); - exists(dir, (e) => { + exists(dir, e => { if (e) { - console.log('\x1b[31m', `-> You dont have permission to use "${share}" directory.` ,'\x1b[0m'); - console.log('\x1b[31m', '-> Use custom directory instead. Example:' ,'\x1b[0m'); - console.log('\x1b[31m', '-> ./install.sh --custom-dir=~/' ,'\x1b[0m'); + console.log('\x1b[31m', `-> You dont have permission to use "${share}" directory.`, '\x1b[0m'); + console.log('\x1b[31m', '-> Use custom directory instead. Example:', '\x1b[0m'); + console.log('\x1b[31m', '-> ./install.sh --custom-dir=~/', '\x1b[0m'); throw e; } - let isNode = process.argv.filter(a => a === '--add_node').length === 0; - 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) => { + const isNode = process.argv.filter(a => a === '--add_node').length === 0; + const run = `#!/usr/bin/env bash\n${isNode ? process.argv[0] : './node'} host.js`; + fs.writeFile(path.join(dir, 'run.sh'), run, e => { if (e) { throw e; } fs.chmodSync(path.join(dir, 'run.sh'), '0755'); - if (!isNode) { - fs.createReadStream('../node').pipe(fs.createWriteStream(path.join(dir, 'node'))); - fs.chmodSync(path.join(dir, 'node'), '0755'); - } fs.createReadStream('host.js').pipe(fs.createWriteStream(path.join(dir, 'host.js'))); fs.createReadStream('config.js').pipe(fs.createWriteStream(path.join(dir, 'config.js'))); fs.createReadStream('messaging.js').pipe(fs.createWriteStream(path.join(dir, 'messaging.js'))); + if (!isNode) { + fs.createReadStream(process.argv[0]).pipe(fs.createWriteStream(path.join(dir, 'node'))); + fs.chmodSync(path.join(dir, 'node'), '0755'); + } callback(); }); }); } -function chrome (callback) { - if (ids.chrome.length) { - let 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) { - let loc = path.join( - process.env.HOME, - '.config/chromium/NativeMessagingHosts' - ); - manifest(loc, 'chrome', callback); - console.error(' -> Chromium 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) { - let 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(() => 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'); }); -}))); +})(); diff --git a/linux/node/x64/node b/linux/node/x64/node index 5d4ce7d..977d008 100755 Binary files a/linux/node/x64/node and b/linux/node/x64/node differ diff --git a/linux/node/x86/ReadMe b/linux/node/x86/ReadMe new file mode 100644 index 0000000..8179d45 --- /dev/null +++ b/linux/node/x86/ReadMe @@ -0,0 +1 @@ +https://unofficial-builds.nodejs.org/download/release/v10.16.3/ diff --git a/linux/node/x86/node b/linux/node/x86/node index 949feba..3a9bdce 100755 Binary files a/linux/node/x86/node and b/linux/node/x86/node differ diff --git a/linux/uninstall.sh b/linux/uninstall.sh index 34a089c..02d61f3 100755 --- a/linux/uninstall.sh +++ b/linux/uninstall.sh @@ -1,25 +1,47 @@ -#!/bin/bash +#!/usr/bin/env bash cd ./app MACHINE_TYPE=`uname -m` -if [ ${MACHINE_TYPE} == 'x86_64' ]; then + +which node 2>/dev/null +isNode=$? +echo NodeJS status = $isNode + +if [ ${isNode} -eq 0 ]; then + echo "Using system NodeJS" + id=`node -e "process.stdout.write(require('./config.js').id)"` +elif [ ${MACHINE_TYPE} == 'x86_64' ]; then + echo "Using ../node/x64/node" id=`../node/x64/node -e "process.stdout.write(require('./config.js').id)"` else + echo "Using ../node/x86/node" id=`../node/x86/node -e "process.stdout.write(require('./config.js').id)"` 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" -rm -r ~/${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 <<<". diff --git a/mac/app/install.js b/mac/app/install.js index 5d2d366..9640525 100644 --- a/mac/app/install.js +++ b/mac/app/install.js @@ -1,26 +1,27 @@ '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] || process.env.HOME; +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)); } share = path.resolve(share); console.log(' -> Root directory is', share); -function exists (directory, callback) { +function exists(directory, callback) { let root = '/'; - let dirs = directory.split('/'); - function one () { + const dirs = directory.split('/'); + function one() { root = path.join(root, dirs.shift()); - fs.stat(root, (e) => { + fs.stat(root, e => { if (!e && dirs.length) { one(); } else if (e && e.code === 'ENOENT') { - fs.mkdir(root, (e) => { + fs.mkdir(root, e => { if (e) { callback(e); } @@ -40,13 +41,13 @@ 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) { +function manifest(root, type, callback) { console.log(' -> Creating a directory at', root); - exists(root, (e) => { + exists(root, e => { if (e) { throw e; } @@ -64,7 +65,7 @@ function manifest (root, type, callback) { "path": "${path.join(dir, 'run.sh')}", "type": "stdio", ${origins} -}`, (e) => { +}`, e => { if (e) { throw e; } @@ -73,80 +74,87 @@ function manifest (root, type, callback) { }); } -function application (callback) { +function application(callback) { console.log(' -> Creating a directory at', dir); - exists(dir, (e) => { + exists(dir, e => { if (e) { - console.log('\x1b[31m', `-> You dont have permission to use "${share}" directory.` ,'\x1b[0m'); - console.log('\x1b[31m', '-> Use custom directory instead. Example:' ,'\x1b[0m'); - console.log('\x1b[31m', '-> ./install.sh --custom-dir=~/' ,'\x1b[0m'); + console.log('\x1b[31m', `-> You dont have permission to use "${share}" directory.`, '\x1b[0m'); + console.log('\x1b[31m', '-> Use custom directory instead. Example:', '\x1b[0m'); + console.log('\x1b[31m', '-> ./install.sh --custom-dir=~/', '\x1b[0m'); throw e; } - let isNode = process.argv.filter(a => a === '--add_node').length === 0; - let run = isNode ? `#!/bin/bash\n${process.argv[2]} host.js` : '#!/bin/bash\n./node host.js'; + const isNode = process.argv.filter(a => a === '--add_node').length === 0; + const run = `#!/usr/bin/env bash\n${isNode ? process.argv[0] : './node'} host.js`; - fs.writeFile(path.join(dir, 'run.sh'), run, (e) => { + fs.writeFile(path.join(dir, 'run.sh'), run, e => { if (e) { throw e; } fs.chmodSync(path.join(dir, 'run.sh'), '0755'); + fs.createReadStream('host.js').pipe(fs.createWriteStream(path.join(dir, 'host.js'))); + fs.createReadStream('config.js').pipe(fs.createWriteStream(path.join(dir, 'config.js'))); + fs.createReadStream('messaging.js').pipe(fs.createWriteStream(path.join(dir, 'messaging.js'))); if (!isNode) { fs.createReadStream(process.argv[0]).pipe(fs.createWriteStream(path.join(dir, 'node'))); fs.chmodSync(path.join(dir, 'node'), '0755'); } - fs.createReadStream('host.js').pipe(fs.createWriteStream(path.join(dir, 'host.js'))); - fs.createReadStream('config.js').pipe(fs.createWriteStream(path.join(dir, 'config.js'))); - fs.createReadStream('messaging.js').pipe(fs.createWriteStream(path.join(dir, 'messaging.js'))); callback(); }); }); } -function chrome (callback) { - if (ids.chrome.length) { - let loc = path.join( - process.env.HOME, - 'Library/Application Support/Google/Chrome/NativeMessagingHosts' - ); - manifest(loc, 'chrome', callback); - console.error(' -> Chrome Browser is supported'); - } - else { - callback(); - } -} -function chromium (callback) { - if (ids.chrome.length) { - let loc = path.join( - process.env.HOME, - 'Library/Application Support/Chromium/NativeMessagingHosts' - ); - manifest(loc, 'chrome', callback); - console.error(' -> Chromium 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('Library/Application Support/Google/Chrome/NativeMessagingHosts'); + console.error(' -> Chrome Browser is supported'); + await run('Library/Application Support/Chromium/NativeMessagingHosts'); + console.error(' -> Chromium Browser is supported'); + await run('Library/Application Support/Vivaldi/NativeMessagingHosts'); + console.error(' -> Vivaldi Browser is supported'); + await run('Library/Application Support/BraveSoftware/Brave-Browser/NativeMessagingHosts'); + console.error(' -> Brave Browser is supported'); + await run('Library/Application Support/Microsoft Edge/NativeMessagingHosts'); + console.error(' -> Microsoft Edge Browser is supported'); } -function firefox (callback) { - if (ids.firefox.length) { - let loc = path.join( - process.env.HOME, - 'Library/Application Support/Mozilla/NativeMessagingHosts' - ); - 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('Library/Application Support/Mozilla/NativeMessagingHosts'); + console.error(' -> Firefox Browser is supported'); + await run('Library/Application Support/Waterfox/NativeMessagingHosts'); + console.error(' -> Waterfox Browser is supported'); + await run('Library/Application Support/TorBrowser-Data/Browser/Mozilla/NativeMessagingHosts'); + console.error(' -> Tor Browser is supported'); + await run('Library/Application Support/Thunderbird/NativeMessagingHosts'); + console.error(' -> Thunderbird Email Client is supported'); } -chrome(() => chromium(() => 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'); }); -}))); +})(); diff --git a/mac/node/x64/node b/mac/node/x64/node index 4d5e2fb..80c671d 100755 Binary files a/mac/node/x64/node and b/mac/node/x64/node differ diff --git a/mac/uninstall.sh b/mac/uninstall.sh index e68e3b1..0ceaef7 100755 --- a/mac/uninstall.sh +++ b/mac/uninstall.sh @@ -1,25 +1,47 @@ -#!/bin/bash +#!/usr/bin/env bash cd ./app MACHINE_TYPE=`uname -m` -if [ ${MACHINE_TYPE} == 'x86_64' ]; then + +which node 2>/dev/null +isNode=$? +echo NodeJS status = $isNode + +if [ ${isNode} -eq 0 ]; then + echo "Using system NodeJS" + id=`node -e "process.stdout.write(require('./config.js').id)"` +elif [ ${MACHINE_TYPE} == 'x86_64' ]; then + echo "Using ../node/x64/node" id=`../node/x64/node -e "process.stdout.write(require('./config.js').id)"` else + echo "Using ../node/x86/node" id=`../node/x86/node -e "process.stdout.write(require('./config.js').id)"` fi echo "Native Client id is \"${id}\"" echo -echo " .. Removing manifest file for Google Chrome" -rm ~/Library/Application\ Support/Google/Chrome/NativeMessagingHosts/${id}.json -echo " .. Removing manifest file for Chromium" -rm ~/Library/Application\ Support/Chromium/NativeMessagingHosts/${id}.json -echo " .. Removing manifest file for Mozilla Firefox" -rm ~/Library/Application\ Support/Mozilla/NativeMessagingHosts/${id}.json -echo " .. Removing executable" -rm -r ~/${id} +echo " -> Removing manifest file for Google Chrome" +rm -f ~/Library/Application\ Support/Google/Chrome/NativeMessagingHosts/${id}.json +echo " -> Removing manifest file for Chromium" +rm -f ~/Library/Application\ Support/Chromium/NativeMessagingHosts/${id}.json +echo " -> Removing manifest file for Vivaldi" +rm -f ~/Library/Application Support/Vivaldi/NativeMessagingHosts/${id}.json +echo " -> Removing manifest file for Brave" +rm -f ~/Library/Application Support/BraveSoftware/Brave-Browser/NativeMessagingHosts/${id}.json +echo " -> Removing manifest file for Microsoft Edge" +rm -f ~/Library/Application Support/Microsoft Edge/NativeMessagingHosts/${id}.json +echo " -> Removing manifest file for Mozilla Firefox" +rm -f ~/Library/Application\ Support/Mozilla/NativeMessagingHosts/${id}.json +echo " -> Removing manifest file for Waterfox" +rm -f ~/Library/Application\ Support/Waterfox/NativeMessagingHosts/${id}.json +echo " -> Removing manifest file for Tor" +rm -f ~/Library/Application Support/TorBrowser-Data/Browser/Mozilla/NativeMessagingHosts/${id}.json +echo " -> Removing manifest file for Thunderbird" +rm -f ~/Library/Application\ Support/Thunderbird/NativeMessagingHosts/${id}.json +echo " -> Removing executables" +[ -n "$id" ] && rm -f -r ~/.config/${id} echo echo ">>> Native Client is removed <<<". diff --git a/messaging.js b/messaging.js index d62ec9c..b78cb89 100644 --- a/messaging.js +++ b/messaging.js @@ -7,119 +7,119 @@ // - Transform - transform message objects to reply objects // - Debug - transform JavaScript objects to lines of JSON (for debugging, obviously) -var stream = require('stream'); -var util = require('util'); +const stream = require('stream'); +const util = require('util'); function Input() { - stream.Transform.call(this); + stream.Transform.call(this); - // Transform bytes... - this._writableState.objectMode = false; - // ...into objects. - this._readableState.objectMode = true; + // Transform bytes... + this._writableState.objectMode = false; + // ...into objects. + this._readableState.objectMode = true; - // Unparsed data. - this.buf = new Buffer(0); - // Parsed length. - this.len = null; + // Unparsed data. + this.buf = Buffer.alloc(0); + // Parsed length. + this.len = null; } util.inherits(Input, stream.Transform); Input.prototype._transform = function(chunk, encoding, done) { - // Save this chunk. - this.buf = Buffer.concat([ this.buf, chunk ]); - - var self = this; - - function parseBuf() { - // Do we have a length yet? - if (typeof self.len !== 'number') { - // Nope. Do we have enough bytes for the length? - if (self.buf.length >= 4) { - // Yep. Parse the bytes. - self.len = self.buf.readUInt32LE(0); - // Remove the length bytes from the buffer. - self.buf = self.buf.slice(4); - } - } - - // Do we have a length yet? (We may have just parsed it.) - if (typeof self.len === 'number') { - // Yep. Do we have enough bytes for the message? - if (self.buf.length >= self.len) { - // Yep. Slice off the bytes we need. - var message = self.buf.slice(0, self.len); - // Remove the bytes for the message from the buffer. - self.buf = self.buf.slice(self.len); - // Clear the length so we know we need to parse it again. - self.len = null; - // Parse the message bytes. - var obj = JSON.parse(message.toString()); - // Enqueue it for reading. - self.push(obj); - // We could have more messages in the buffer so check again. - parseBuf(); - } - } + // Save this chunk. + this.buf = Buffer.concat([this.buf, chunk]); + + const self = this; + + function parseBuf() { + // Do we have a length yet? + if (typeof self.len !== 'number') { + // Nope. Do we have enough bytes for the length? + if (self.buf.length >= 4) { + // Yep. Parse the bytes. + self.len = self.buf.readUInt32LE(0); + // Remove the length bytes from the buffer. + self.buf = self.buf.slice(4); + } } - // Check for a parsable buffer (both length and message). - parseBuf(); + // Do we have a length yet? (We may have just parsed it.) + if (typeof self.len === 'number') { + // Yep. Do we have enough bytes for the message? + if (self.buf.length >= self.len) { + // Yep. Slice off the bytes we need. + const message = self.buf.slice(0, self.len); + // Remove the bytes for the message from the buffer. + self.buf = self.buf.slice(self.len); + // Clear the length so we know we need to parse it again. + self.len = null; + // Parse the message bytes. + const obj = JSON.parse(message.toString()); + // Enqueue it for reading. + self.push(obj); + // We could have more messages in the buffer so check again. + parseBuf(); + } + } + } + + // Check for a parsable buffer (both length and message). + parseBuf(); - // We're done. - done(); + // We're done. + done(); }; function Output() { - stream.Transform.call(this); + stream.Transform.call(this); - this._writableState.objectMode = true; - this._readableState.objectMode = false; + this._writableState.objectMode = true; + this._readableState.objectMode = false; } util.inherits(Output, stream.Transform); Output.prototype._transform = function(chunk, encoding, done) { - var len = new Buffer(4); - var buf = new Buffer(JSON.stringify(chunk)); + const len = Buffer.alloc(4); + const buf = Buffer.from(JSON.stringify(chunk), 'utf8'); - len.writeUInt32LE(buf.length, 0); + len.writeUInt32LE(buf.length, 0); - this.push(len); - this.push(buf); + this.push(len); + this.push(buf); - done(); + done(); }; function Transform(handler) { - stream.Transform.call(this); + stream.Transform.call(this); - this._writableState.objectMode = true; - this._readableState.objectMode = true; + this._writableState.objectMode = true; + this._readableState.objectMode = true; - this.handler = handler; + this.handler = handler; } util.inherits(Transform, stream.Transform); Transform.prototype._transform = function(msg, encoding, done) { - this.handler(msg, this.push.bind(this), done); + this.handler(msg, this.push.bind(this), done); }; function Debug() { - stream.Transform.call(this); + stream.Transform.call(this); - this._writableState.objectMode = true; - this._readableState.objectMode = false; + this._writableState.objectMode = true; + this._readableState.objectMode = false; } util.inherits(Debug, stream.Transform); Debug.prototype._transform = function(chunk, encoding, done) { - this.push(JSON.stringify(chunk) + '\n'); + this.push(JSON.stringify(chunk) + '\n'); - done(); + done(); }; exports.Input = Input; diff --git a/prepare.sh b/prepare.sh index 6c4cd7b..33db06b 100755 --- a/prepare.sh +++ b/prepare.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash cd linux zip ../linux.zip -9 -r * -x "*.DS_Store" diff --git a/windows/app/install.js b/windows/app/install.js index 6255882..a35ac7e 100644 --- a/windows/app/install.js +++ b/windows/app/install.js @@ -1,10 +1,10 @@ 'use strict'; -var fs = require('fs'); -var path = require('path'); +const fs = require('fs'); +const path = require('path'); -function exists (directory, callback) { - fs.stat(directory, (e) => { +function exists(directory, callback) { + fs.stat(directory, e => { if (e && e.code === 'ENOENT') { fs.mkdir(directory, callback); @@ -15,22 +15,38 @@ function exists (directory, callback) { }); } -var {id, ids} = require('./config.js'); -var dir = path.join(process.argv[2], id); -var name = id; +const {id, ids} = require('./config.js'); +const dir = path.join(process.argv[2], id); +const name = id; -var {exec} = require('child_process'); +const {exec} = require('child_process'); -console.log('.. Writting to Chrome Registry'); +console.log('.. Writing to Chrome Registry'); console.log(`.. Key: HKCU\\Software\\Google\\Chrome\\NativeMessagingHosts\\${id}`); exec(`REG ADD "HKCU\\Software\\Google\\Chrome\\NativeMessagingHosts\\${id}" /ve /t REG_SZ /d "%LocalAPPData%\\${id}\\manifest-chrome.json" /f`); -console.log(`.. Writting to Firefox Registry`); +console.log('.. Writing to Chromium Registry'); +console.log(`.. Key: HKEY_CURRENT_USER\\Software\\Chromium\\NativeMessagingHosts\\${id}`); +exec(`REG ADD "HKEY_CURRENT_USER\\Software\\Chromium\\NativeMessagingHosts\\${id}" /ve /t REG_SZ /d "%LocalAPPData%\\${id}\\manifest-chrome.json" /f`); + +console.log('.. Writing to Edge Registry'); +console.log(`.. Key: HKEY_CURRENT_USER\\Software\\Microsoft\\Edge\\NativeMessagingHosts\\${id}`); +exec(`REG ADD "HKEY_CURRENT_USER\\Software\\Microsoft\\Edge\\NativeMessagingHosts\\${id}" /ve /t REG_SZ /d "%LocalAPPData%\\${id}\\manifest-chrome.json" /f`); + +console.log(`.. Writing to Firefox Registry`); console.log(`.. Key: HKCU\\SOFTWARE\\Mozilla\\NativeMessagingHosts\\${id}`); exec(`REG ADD "HKCU\\SOFTWARE\\Mozilla\\NativeMessagingHosts\\${id}" /ve /t REG_SZ /d "%LocalAPPData%\\${id}\\manifest-firefox.json" /f`); -function manifest (type, callback) { - exists(dir, (e) => { +console.log(`.. Writing to Waterfox Registry`); +console.log(`.. Key: HKCU\\SOFTWARE\\Waterfox\\NativeMessagingHosts\\${id}`); +exec(`REG ADD "HKCU\\SOFTWARE\\Waterfox\\NativeMessagingHosts\\${id}" /ve /t REG_SZ /d "%LocalAPPData%\\${id}\\manifest-firefox.json" /f`); + +console.log(`.. Writing to Thunderbird Registry`); +console.log(`.. Key: HKCU\\SOFTWARE\\Thunderbird\\NativeMessagingHosts\\${id}`); +exec(`REG ADD "HKCU\\SOFTWARE\\Thunderbird\\NativeMessagingHosts\\${id}" /ve /t REG_SZ /d "%LocalAPPData%\\${id}\\manifest-firefox.json" /f`); + +function manifest(type, callback) { + exists(dir, e => { if (e) { throw e; } @@ -47,7 +63,7 @@ function manifest (type, callback) { "path": "run.bat", "type": "stdio", ${origins} -}`, (e) => { +}`, e => { if (e) { throw e; } @@ -55,8 +71,8 @@ function manifest (type, callback) { }); }); } -function application (callback) { - fs.writeFile(path.join(dir, 'run.bat'), `@echo off\n\n"%~dp0node.exe" "%~dp0host.js"`, (e) => { +function application(callback) { + fs.writeFile(path.join(dir, 'run.bat'), `@echo off\n\n"%~dp0node.exe" "%~dp0host.js"`, e => { if (e) { throw e; } @@ -65,12 +81,13 @@ function application (callback) { fs.createReadStream('messaging.js').pipe(fs.createWriteStream(path.join(dir, 'messaging.js'))); try { fs.createReadStream(process.argv[0]).pipe(fs.createWriteStream(path.join(dir, 'node.exe'))); - } catch (e) {} + } + catch (e) {} callback(); }); } -function chrome (callback) { +function chrome(callback) { if (ids.chrome.length) { manifest('chrome', callback); console.error('.. Chrome Browser is supported'); @@ -79,7 +96,7 @@ function chrome (callback) { callback(); } } -function firefox (callback) { +function firefox(callback) { if (ids.firefox.length) { manifest('firefox', callback); console.error('.. Firefox Browser is supported'); diff --git a/windows/install.bat b/windows/install.bat index d5fc87c..7563eae 100644 --- a/windows/install.bat +++ b/windows/install.bat @@ -1,5 +1,7 @@ @echo off +SET PATH=C:\Windows\System32;%PATH% + pushd "%~dp0" CD app diff --git a/windows/node/x64/node.exe b/windows/node/x64/node.exe index c668710..399aa43 100755 Binary files a/windows/node/x64/node.exe and b/windows/node/x64/node.exe differ diff --git a/windows/node/x86/node.exe b/windows/node/x86/node.exe index 4bdbbbf..4a9005c 100755 Binary files a/windows/node/x86/node.exe and b/windows/node/x86/node.exe differ diff --git a/windows/uninstall.bat b/windows/uninstall.bat index d8e2fd1..5fcd798 100644 --- a/windows/uninstall.bat +++ b/windows/uninstall.bat @@ -14,10 +14,21 @@ echo sss%id% echo .. Deleting Chrome Registry REG DELETE "HKCU\Software\Google\Chrome\NativeMessagingHosts\%id%" /f +echo .. Deleting Chromium Registry +REG DELETE "HKEY_CURRENT_USER\Software\Chromium\NativeMessagingHosts\%id%" /f + +echo .. Deleting Microsoft Edge Registry +REG DELETE "HKEY_CURRENT_USER\Software\Microsoft\Edge\NativeMessagingHosts\%id%" /f + echo .. Deleting Firefox Registry -for %%f in ("%LocalAPPData%") do SET SHORT_PATH=%%~sf REG DELETE "HKCU\SOFTWARE\Mozilla\NativeMessagingHosts\%id%" /f +echo .. Deleting Waterfox Registry +REG DELETE "HKCU\SOFTWARE\Waterfox\NativeMessagingHosts\%id%" /f + +echo .. Deleting Thunderbird Registry +REG DELETE "HKCU\SOFTWARE\Thunderbird\NativeMessagingHosts\%id%" /f + echo .. Deleting %id% RMDIR /Q /S "%LocalAPPData%\%id%" @@ -25,4 +36,3 @@ echo. echo ^>^>^> Native Client is removed ^<^<^< echo. pause -