All Projects → simov → native-messaging

simov / native-messaging

Licence: MIT license
Native Messaging Host Protocol for Browser Extensions

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to native-messaging

security.txt
ℹ️ Cross-platform browser extension for discovering security.txt and humans.txt files.
Stars: ✭ 15 (-62.5%)
Mutual labels:  firefox-addon, firefox-extension, browser-extension
Blazor.BrowserExtension
A package for building Browser Extension with Blazor WebAssembly application.
Stars: ✭ 207 (+417.5%)
Mutual labels:  firefox-addon, firefox-extension, browser-extension
Nxenhanced
Adds "quality-of-life" features to NextDNS website for a more practical usability
Stars: ✭ 58 (+45%)
Mutual labels:  firefox-addon, firefox-extension, browser-extension
locale-switcher
Browser Extension to quickly change your browser locale.
Stars: ✭ 75 (+87.5%)
Mutual labels:  firefox-addon, firefox-extension, browser-extension
LAN-port-scan-forbidder
Forbid untrusted webs to access localhost or LAN. An anti-scan protection 🛡️🏡
Stars: ✭ 53 (+32.5%)
Mutual labels:  firefox-addon, firefox-extension, browser-extension
Markdown Viewer
Markdown Viewer / Browser Extension
Stars: ✭ 497 (+1142.5%)
Mutual labels:  firefox-addon, firefox-extension, browser-extension
Turn-Off-the-Lights-Firefox-extension-WebExtensions
Firefox extension (WebExtensions)
Stars: ✭ 19 (-52.5%)
Mutual labels:  firefox-addon, firefox-extension, browser-extension
AntiRickRoll
Chrome extension that blocks Rickrolls!
Stars: ✭ 22 (-45%)
Mutual labels:  firefox-addon, firefox-extension, browser-extension
quickjira
🚤 📂 Quickly access the JIRA of your choice by typing the ticket id
Stars: ✭ 65 (+62.5%)
Mutual labels:  firefox-addon, firefox-extension, browser-extension
Notion-Boost-browser-extension
Chrome & Firefox extension for Notion to add 20+ features like sticky outline, small text & full width by default, hide comments & help button, bolder text etc. Download here: https://gourav.io/notion-boost
Stars: ✭ 367 (+817.5%)
Mutual labels:  firefox-addon, firefox-extension, browser-extension
Read Aloud
An awesome browser extension that reads aloud webpage content with one click
Stars: ✭ 444 (+1010%)
Mutual labels:  firefox-addon, firefox-extension, browser-extension
selecton-extension
Selecton provides popup with actions on text selection in all major browsers
Stars: ✭ 36 (-10%)
Mutual labels:  firefox-addon, firefox-extension, browser-extension
Extanalysis
Browser Extension Analysis Framework - Scan, Analyze Chrome, firefox and Brave extensions for vulnerabilities and intels
Stars: ✭ 351 (+777.5%)
Mutual labels:  firefox-addon, firefox-extension, browser-extension
hackernews-button
Privacy-preserving Firefox extension linking to Hacker News discussion; built with Bloom filters and WebAssembly
Stars: ✭ 73 (+82.5%)
Mutual labels:  firefox-addon, firefox-extension, browser-extension
VRCFriendCheck
VRChatのフレンドのオンライン状況の確認、オンライン通知ができるブラウザ拡張機能
Stars: ✭ 16 (-60%)
Mutual labels:  firefox-addon, firefox-extension, browser-extension
Turnoff Namuwiki
조별과제 때마다 "나무위키 꺼라."라고 말하시는게 피곤하신 여러분을 위해 만들어진 Browser Extension, 나무위키를 꺼 드립니다.
Stars: ✭ 59 (+47.5%)
Mutual labels:  firefox-addon, firefox-extension, browser-extension
inDoors
Chrome/Firefox extension that displays companies' Glassdoor ratings on LinkedIn and other job sites
Stars: ✭ 33 (-17.5%)
Mutual labels:  firefox-addon, firefox-extension, browser-extension
linguist
Linguist is a powerful browser extension for translate pages and text, which are ready to replace your favorite translate service
Stars: ✭ 21 (-47.5%)
Mutual labels:  firefox-addon, firefox-extension, browser-extension
Spotify Lyrics
🎉 Desktop Spotify Web Player Instant Synchronised Lyrics
Stars: ✭ 162 (+305%)
Mutual labels:  firefox-addon, firefox-extension, browser-extension
snoozz-tab-snoozing
A Web Extension to declutter windows by snoozing tabs for later
Stars: ✭ 105 (+162.5%)
Mutual labels:  firefox-addon, firefox-extension, browser-extension

native-messaging

npm-version

Native Messaging Host Protocol for Browser Extensions (Chrome, Firefox)

API

#!/home/s/.nvm/versions/node/v8.11.2/bin/node

// Might be good to use an explicit path to node on the shebang line
// in case it isn't in PATH when launched by Chrome/Firefox

var sendMessage = require('native-messaging')(handleMessage)

function handleMessage (req) {
  if (req.message === 'ping') {
    sendMessage({message: 'pong', body: 'hello from nodejs app'})
  }
}

Tips

  • chrome.runtime.connectNative returns a Port that can be used to establish persistent connection between the browser and the native app
  • the Port's disconnect method can be used to disconnect from the native app
  • the native app can use the OS's machinery to kill its own process at any time
  • chrome.runtime.sendNativeMessage can be used to send single message to the native app, useful with non persistent background pages
  • single native app can communicate with multiple browser extensions
  • single browser extension can communicate with multiple native apps

Things to look for

  1. Add nativeMessaging permission to the manifest.json file of your extension
  2. Load the extension to get its ID generated
  3. Put the native.messaging.example.json in ~/.config/google-chrome/NativeMessagingHosts/ or ~/.mozilla/native-messaging-hosts/
  • The name of the file should be identical to the name field specified in that file
  • Only dots . are allowed as delimiters in the file name
  • The path key should be absolute path to your nodejs script example.js
  • Chrome - the allowed_origins key should contain the extension's ID loaded in step 2
  • Firefox - the allowed_extensions key should contain the extension's ID specified in its manifest.json file
  1. Make sure that example.js is executable chmod 755
  2. Make sure nodejs is reachable from the shebang line in example.js
  3. Use the name specified in native.messaging.example.json to connect to the native app from the extension's background page background.js

Note that the install location for the native.messaging.example.json differs for each OS and browser. In case you plan to support multiple platforms, it's best to use install script. Here is an example of such script.

References

Topic Chrome Firefox
Native Messaging Host Protocol link link
chrome.runtime.connectNative link link
Port link link
chrome.runtime.sendNativeMessage link link
host.json location link link
official example link link
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].