{"id":13587926,"url":"https://github.com/alexherbo2/webextension-shell","last_synced_at":"2025-08-02T21:31:02.325Z","repository":{"id":75997437,"uuid":"212631803","full_name":"alexherbo2/webextension-shell","owner":"alexherbo2","description":"WebExtension API to execute external commands through native messaging","archived":false,"fork":false,"pushed_at":"2023-10-21T17:46:44.000Z","size":32,"stargazers_count":16,"open_issues_count":0,"forks_count":5,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-05-21T04:25:01.599Z","etag":null,"topics":["api","chrome","firefox","native-messaging","webextension"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alexherbo2.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING","funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-10-03T16:54:35.000Z","updated_at":"2024-08-01T16:34:11.184Z","dependencies_parsed_at":"2024-08-01T16:43:56.673Z","dependency_job_id":null,"html_url":"https://github.com/alexherbo2/webextension-shell","commit_stats":null,"previous_names":["alexherbo2/chrome-shell"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexherbo2%2Fwebextension-shell","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexherbo2%2Fwebextension-shell/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexherbo2%2Fwebextension-shell/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexherbo2%2Fwebextension-shell/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alexherbo2","download_url":"https://codeload.github.com/alexherbo2/webextension-shell/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228500241,"owners_count":17930015,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","chrome","firefox","native-messaging","webextension"],"created_at":"2024-08-01T15:06:25.621Z","updated_at":"2024-12-06T17:20:13.795Z","avatar_url":"https://github.com/alexherbo2.png","language":"Shell","funding_links":[],"categories":["Shell"],"sub_categories":[],"readme":"# Shell for [Chrome] and [Firefox] – [WebExtensions]\n\n[Chrome]: https://google.com/chrome/\n[Firefox]: https://mozilla.org/firefox/\n[WebExtensions]: https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions\n\n\u003cimg src=\"https://github.com/FortAwesome/Font-Awesome/raw/master/svgs/solid/terminal.svg\" height=\"16\" align=\"right\"\u003e\n\n[WebExtension][WebExtensions] API to execute external commands through [native messaging].\n\n[Native messaging]: https://developer.chrome.com/extensions/nativeMessaging\n\n## Dependencies\n\n- [Crystal]\n- [jq]\n\n[Crystal]: https://crystal-lang.org\n[jq]: https://stedolan.github.io/jq/\n\n## Installation\n\n1. [Host](host)\n2. [Extension](extension)\n\n## Usage\n\n``` javascript\n// Environment variables\nswitch (true) {\n  case (typeof browser !== 'undefined'):\n    var PLATFORM = 'firefox'\n    var SHELL_EXTENSION_ID = 'shell@alexherbo2.github.com'\n    break\n  case (typeof chrome !== 'undefined'):\n    var PLATFORM = 'chrome'\n    var SHELL_EXTENSION_ID = 'ohgecdnlcckpfnhjepfdcdgcfgebkdgl'\n    break\n}\n\n// Initialization\nconst shell = {}\nshell.port = chrome.runtime.connect(SHELL_EXTENSION_ID)\nshell.send = (command, ...arguments) =\u003e {\n  shell.port.postMessage({ command, arguments })\n}\n\n// Usage\nshell.send('mpv', 'https://youtu.be/7ky_itVPTnk')\n```\n\n###### Ping-pong\n\n``` javascript\nconst ping = () =\u003e {\n  shell.port.postMessage({\n    id: 'ping-pong',\n    command: 'echo',\n    arguments: ['Ping']\n  })\n}\n\nshell.port.onMessage.addListener((response) =\u003e {\n  switch (response.id) {\n    case 'ping-pong':\n      console.log(response.output, 'Pong')\n      break\n  }\n})\n\n// Ping-pong\nping()\n```\n\nYou can find some examples in [Krabby].\n\n[Krabby]: https://krabby.netlify.app\n\nSee the [source](host/src) for a complete reference.\n\n## API\n\n###### Request\n\n``` crystal\n{\n  id: String?,\n  command: String,\n  arguments: Array(String)?,\n  environment: Hash(String, String)?,\n  shell: { type: Bool, default: false },\n  input: String?,\n  directory: String?\n}\n```\n\n###### Response\n\n``` crystal\n{\n  id: String?,\n  status: Int32,\n  output: String,\n  error: String\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexherbo2%2Fwebextension-shell","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falexherbo2%2Fwebextension-shell","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexherbo2%2Fwebextension-shell/lists"}