{"id":15711361,"url":"https://github.com/extend-chrome/clipboard","last_synced_at":"2025-05-07T02:44:04.714Z","repository":{"id":44587708,"uuid":"173202450","full_name":"extend-chrome/clipboard","owner":"extend-chrome","description":"Use the clipboard with ease in Chrome extensions.","archived":false,"fork":false,"pushed_at":"2023-08-03T06:41:35.000Z","size":227,"stargazers_count":28,"open_issues_count":5,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-31T05:33:13.079Z","etag":null,"topics":["chrome-extension","chrome-extensions","clipboard","clipboard-api","javascript","javascript-library","npm-module"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/extend-chrome.png","metadata":{"funding":{"ko_fi":"jacksteam"},"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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-02-28T23:22:20.000Z","updated_at":"2025-03-16T07:52:44.000Z","dependencies_parsed_at":"2024-10-24T09:38:45.819Z","dependency_job_id":"d7ffd847-2014-45d4-ba82-2c774ef850b9","html_url":"https://github.com/extend-chrome/clipboard","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/extend-chrome%2Fclipboard","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/extend-chrome%2Fclipboard/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/extend-chrome%2Fclipboard/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/extend-chrome%2Fclipboard/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/extend-chrome","download_url":"https://codeload.github.com/extend-chrome/clipboard/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246557983,"owners_count":20796696,"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-extension","chrome-extensions","clipboard","clipboard-api","javascript","javascript-library","npm-module"],"created_at":"2024-10-03T21:12:41.935Z","updated_at":"2025-03-31T23:31:34.566Z","avatar_url":"https://github.com/extend-chrome.png","language":"TypeScript","funding_links":["https://ko-fi.com/jacksteam"],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://github.com/extend-chrome/clipboard\" rel=\"noopener\"\u003e\n \u003cimg width=200px height=200px src=\"https://i.imgur.com/Pw8LMCb.png\" alt=\"@extend-chrome/clipboard\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n\u003ch3 align=\"center\"\u003e@extend-chrome/clipboard\u003c/h3\u003e\n\n\u003cdiv align=\"center\"\u003e\n\n[![npm (scoped)](https://img.shields.io/npm/v/@extend-chrome/clipboard.svg)](https://www.npmjs.com/package/@extend-chrome/clipboard)\n[![GitHub last commit](https://img.shields.io/github/last-commit/extend-chrome/clipboard.svg)](https://github.com/extend-chrome/clipboard)\n[![License](https://img.shields.io/badge/license-MIT-blue.svg)](/LICENSE)\n[![TypeScript Declarations Included](https://img.shields.io/badge/types-TypeScript-informational)](#typescript)\n\n\u003c/div\u003e\n\n\u003cdiv align=\"center\"\u003e\n\n[![Chrome Extension Tutorials on YouTube](https://img.shields.io/badge/Chrome%20Extension%20Tutorials-YouTube-c4302b.svg)](https://www.youtube.com/channel/UCVj3dGw75v8aHFYD6CL1tFg)\n[![ko-fi](https://img.shields.io/badge/Buy%20us%20a%20tea-ko--fi-29ABE0)](https://ko-fi.com/jacksteam)\n\n\u003c/div\u003e\n\n---\n\nUsing the clipboard in a Chrome Extension can be a pain. The async Clipboard API [doesn't work in background scripts](https://bugs.chromium.org/p/chromium/issues/detail?id=874848\u0026can=1\u0026q=chrome%20extension%20clipboard%20api\u0026colspec=ID%20Pri%20M%20Stars%20ReleaseBlock%20Component%20Status%20Owner%20Summary%20OS%20Modified) and workarounds require lots of boilerplate. This library works in all MV2 Chrome extension contexts. It emulates the [Clipboard API](https://developer.mozilla.org/en-US/docs/Web/API/Clipboard_API) `readText` and `writeText` methods using `document.execCommand`.\n\n## Table of Contents\n\n- [Getting Started](#getting_started)\n- [Usage](#usage)\n\n## Getting started \u003ca name = \"getting_started\"\u003e\u003c/a\u003e\n\nYou will need to use a bundler like [Rollup](https://rollupjs.org/guide/en/) or Webpack to include this library in the build of Chrome extension.\n\nSee [`rollup-plugin-chrome-extension`](https://github.com/extend-chrome/rollup-plugin-chrome-extension) for an easy way use Rollup to build your Chrome extension!\n\n### Installation\n\n```sh\n$ npm i @extend-chrome/clipboard\n```\n\nAdd the [permissions](https://developer.chrome.com/extensions/declare_permissions) `\"clipboardRead\"` and/or `\"clipboardWrite\"` to your [`manifest.json`](https://developer.chrome.com/extensions/manifest). Remember, only request the permissions you need! For example, if your extension only reads the clipboard, only request `\"clipboardRead\"`.\n\n```json\n{\n  \"permissions\": [\"clipboardRead\", \"clipboardWrite\"]\n}\n```\n\n### TypeScript Definitions \u003ca name = \"typescript\"\u003e\u003c/a\u003e\n\nTypeScript definitions are included, so no need to install an additional `@types` library!\n\n## Usage \u003ca name = \"usage\"\u003e\u003c/a\u003e\n\n```javascript\nimport { clipboard } from '@extend-chrome/clipboard'\n\n// Read text from the clipboard, or \"paste\"\nclipboard.readText().then((text) =\u003e {\n  console.log('clipboard contents', text)\n})\n\n// Write text to the clipboard, or \"copy\"\nclipboard.writeText('write this to the clipboard').then((text) =\u003e {\n  console.log(text, 'was written to the clipboard')\n})\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fextend-chrome%2Fclipboard","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fextend-chrome%2Fclipboard","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fextend-chrome%2Fclipboard/lists"}