script/note.sh is a shell script to post or update local Markdown files as drafts on note.com. It can automatically obtain authentication cookies using a Playwright-based Node script that the script temporarily generates. It also handles image uploads, converts Markdown to basic HTML, and appends tags.
- The included
.env.samplecontains only placeholder values and no real secrets. Do not commit your real.envto a public repository. note.shis designed to useNOTE_EMAIL/NOTE_PASSWORDfrom.envto automatically obtainNOTE_COOKIE. When successful it writes the cookie back into the repository.env. Therefore, always keep your runtime.envin.gitignoreand do not publish it.
- bash (the script is written for POSIX-compatible shells)
- jq (for JSON parsing)
- curl
- Node.js + npm (required only if you use the automatic cookie retrieval)
- Playwright (the script automatically runs
npm installandnpx playwright install chromiumwhen needed)
Create a local .env (do not commit) and set at least:
# NOTE_EMAIL and NOTE_PASSWORD are used for automatic cookie retrieval
NOTE_EMAIL="your-email@example.com"
NOTE_PASSWORD="your-password"
# NOTE_COOKIE is written after successful auto-login
NOTE_COOKIE=""
NOTE_USER_AGENT="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) ..."Basic:
./script/note.sh path/to/article.mdOptions:
--tags "tag1,tag2"— add tags to the post (appends HTML-level hashtags to the content)--update-id ID— update an existing draft by its note ID
If NOTE_COOKIE is empty or unset, the script attempts to log in with NOTE_EMAIL/NOTE_PASSWORD using Playwright. It creates a temporary temp_cookie_getter.js, runs it to obtain cookies, writes NOTE_COOKIE into .env, and then removes the temporary script.
- Never store credentials or API tokens (email, password, Slack tokens, API keys, etc.) in a repository file tracked by Git. Keep
.envlocal and out of version control. - The automatic cookie retrieval expands authentication values into a Node script (temporary file). Verify that
temp_cookie_getter.jsis removed after use and avoid running this on untrusted machines. NOTE_COOKIEis sensitive (it maintains logged-in state). Do not publish it.
- Loads
.env; ifNOTE_COOKIEis missing it tries auto-retrieval. - Removes YAML frontmatter from Markdown and converts basic Markdown to HTML.
- Uploads local images referenced by relative paths to note.com's image upload API and replaces paths with uploaded URLs.
- Creates a new draft or saves/updates an existing draft via the note.com API.
If you want changes to wording, a shorter README, or a translated README for other languages, tell me which parts to adjust.