{"id":13686098,"url":"https://github.com/hcfyapp/chrome-call","last_synced_at":"2025-05-01T05:31:40.018Z","repository":{"id":57198398,"uuid":"48980032","full_name":"hcfyapp/chrome-call","owner":"hcfyapp","description":"Call the original chrome javascript API and return a Promise.","archived":true,"fork":false,"pushed_at":"2018-08-27T19:28:05.000Z","size":120,"stargazers_count":21,"open_issues_count":0,"forks_count":5,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-23T03:04:09.404Z","etag":null,"topics":["chrome-api","chrome-app","chrome-extension","es6","promise"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hcfyapp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-01-04T06:55:19.000Z","updated_at":"2023-01-28T05:17:03.000Z","dependencies_parsed_at":"2022-09-16T13:10:31.777Z","dependency_job_id":null,"html_url":"https://github.com/hcfyapp/chrome-call","commit_stats":null,"previous_names":["lmk123/chrome-call"],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hcfyapp%2Fchrome-call","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hcfyapp%2Fchrome-call/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hcfyapp%2Fchrome-call/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hcfyapp%2Fchrome-call/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hcfyapp","download_url":"https://codeload.github.com/hcfyapp/chrome-call/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251830449,"owners_count":21650802,"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":["chrome-api","chrome-app","chrome-extension","es6","promise"],"created_at":"2024-08-02T14:01:06.078Z","updated_at":"2025-05-01T05:31:39.749Z","avatar_url":"https://github.com/hcfyapp.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"# chrome-call [![Build Status](https://img.shields.io/travis/Selection-Translator/chrome-call/master.svg?style=flat-square)](https://travis-ci.org/Selection-Translator/chrome-call) [![Coverage Status](https://img.shields.io/coveralls/Selection-Translator/chrome-call/master.svg?style=flat-square)](https://coveralls.io/github/Selection-Translator/chrome-call?branch=master) [![NPM Version](https://img.shields.io/npm/v/chrome-call.svg?style=flat-square)](https://www.npmjs.com/package/chrome-call)\n\nCall the [Chrome JavasScript APIs](https://developer.chrome.com/extensions/api_index) then return a Promise.\n\n## Install\n\n### Use with webpack\n\nIf you build your project with webpack, then you can install chrome-call from npm:\n\n```\nnpm install chrome-call\n```\n\nthen you can import it in your project:\n\n```js\n// es6\nimport chromeCall from 'chrome-call'\n\n// commonjs\nconst chromeCall = require('chrome-call')\n```\n\n### Use with \u0026lt;script\u0026gt;\n\nDownload chrome-call.js from [unpkg](https://unpkg.com/chrome-call)([min version](https://unpkg.com/chrome-call/dist/chrome-call.min.js)), then reference it in your html:\n\n```html\n\u003cscript src=\"path/to/chrome-call.js\"\u003e\u003c/script\u003e\n\u003c!-- now you will get a global variable named chromeCall --\u003e\n\u003cscript\u003e\n  typeof chromeCall // function\n\u003c/script\u003e\n```\n\n## Usage\n\nWhen you do:\n\n```js\nconst promise = new Promise((resolve, reject) =\u003e {\n  chrome.tabs.sendMessage(tabId, message, options, response =\u003e {\n    if (chrome.runtime.lastError) {\n      reject(chrome.runtime.lastError)\n    } else {\n      resolve(response)\n    }\n  })\n})\n```\n\nIt's equal to:\n\n```js\nconst promise = chromeCall(chrome.tabs, 'sendMessage', tabId, message, options)\n```\n\nThat's really simple, right?\n\n### Multiple arguments in callback\n\nMost of chrome API only has zero or one argument in callback, but someone not, such as [chrome.hid.receive](https://developer.chrome.com/apps/hid#method-receive).\n\nIn this situation, pass `true` as the first argument, then the value of promise will be an **real** Array:\n\n```js\nimport chromeCall from 'chrome-call'\n\nchromeCall(true, chrome.hid, 'receive', connectionId).then(args =\u003e {\n  Array.isArray(args) // true\n  const reportId = args[0]\n  const data = args[1]\n})\n```\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhcfyapp%2Fchrome-call","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhcfyapp%2Fchrome-call","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhcfyapp%2Fchrome-call/lists"}