Skip to content

azu/uni-clipboard

Repository files navigation

Uni-Clipboard API

Universal Clipboard API service on Cloudflare Workers.

  • Create own clipboard API service
  • Simple GET/POST API
  • Delete data automatically. Default: 60 seconds

Setup

1. Fork and Deploy to Cloudflare Workers

Deploy to Cloudflare Workers

This button introduce Fork this repo and set GitHub Actions to deploy to Cloudflare Workers.

2. Bind UNI_CLIPBOARD to KV namespaces

On Web:

  1. Create Worker KV namespace from https://dash.cloudflare.com/{yourid}/workers/kv/namespaces
    • Namespace Name: your favorite name
  2. Bind Created KV to UNI_CLIPBOARD from https://dash.cloudflare.com/{yourid}/workers/services/view/uni-clipboard/production/settings/bindings
    • Variable Name: UNI_CLIPBOARD
    • KV Namespace: Created KV namespace

On Local:

npx wrangler kv:namespace create "UNI_CLIPBOARD"

3. Put UNI_TOKEN for your access token

On Web:

  1. Input your access token to UNI_TOKEN from https://dash.cloudflare.com/{yourid}/workers/services/view/uni-clipboard/production/settings/bindings
    • Variable name: UNI_TOKEN
    • Value: your access token

On Local:

$ npx wrangler secret put UNI_TOKEN
XXX

Usage

Get clipboard

await fetch('https://uni-clipboard.{your}.workers.dev/?token=XXX')

Update clipboard

await fetch("https://uni-clipboard.{your}.workers.dev/?token=XXX", { method: "post", body: "New Content"})

Redirect to clipboard

https://uni-clipboard.{your}.workers.dev/?token=XXX&redirect=1

Client

You can use Shortcuts and Alfred as client.

For example, Alfred allow you to use ShellScript.

Push your clipboard to uni-clipboard.

c=$(pbpaste | /usr/local/bin/jq -aRs .)
curl -X POST -H "Content-Type: application/json" -d "{\"value\":${c}}" \
"https://uni-clipboard.{you}.workers.dev/?token={token}"

Read clipboard text from uni-clipboard

curl "https://uni-clipboard.{you}.workers.dev/?token={token}" | pbocpy

Development

wranger dev

Deploy

wranger publish

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

License

MIT

About

Universal Clipboard API

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

 

Packages

No packages published