Skip to content

Aki2022/obsidian_note

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

note.sh — Usage (English)

Overview

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.

Key points for public repositories

  • The included .env.sample contains only placeholder values and no real secrets. Do not commit your real .env to a public repository.
  • note.sh is designed to use NOTE_EMAIL / NOTE_PASSWORD from .env to automatically obtain NOTE_COOKIE. When successful it writes the cookie back into the repository .env. Therefore, always keep your runtime .env in .gitignore and do not publish it.

Prerequisites (macOS assumed)

  • 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 install and npx playwright install chromium when needed)

Minimal .env example

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) ..."

Usage

Basic:

./script/note.sh path/to/article.md

Options:

  • --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

Automatic cookie retrieval

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.

Security & privacy notes

  • Never store credentials or API tokens (email, password, Slack tokens, API keys, etc.) in a repository file tracked by Git. Keep .env local and out of version control.
  • The automatic cookie retrieval expands authentication values into a Node script (temporary file). Verify that temp_cookie_getter.js is removed after use and avoid running this on untrusted machines.
  • NOTE_COOKIE is sensitive (it maintains logged-in state). Do not publish it.

What the script does

  • Loads .env; if NOTE_COOKIE is 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.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages