Skip to content

Instantly share code, notes, and snippets.

@t9md
Last active January 28, 2022 06:16
Show Gist options
  • Save t9md/539e774c4d417011b1051b3355fa1b56 to your computer and use it in GitHub Desktop.
Save t9md/539e774c4d417011b1051b3355fa1b56 to your computer and use it in GitHub Desktop.
kindle のハイライトページからハイライトをクリップボードにコピーするブックマークレット

Kindleのハイライトをクリップボードにコピーする。

※ Inspired by さくさんの note 多読多聴 さらに楽しくするために

Kindleのハイライトをクリップボードにコピーする。 以下の両方のサイトで動作する事をMacBook の Chromeで確認しました。

ブックマークレットの作り方

  1. このページをブックマークします。ブックマックバーにブックマークするのがおすすめ。
  2. ブックマークを Edit して、以下のテキストを貼り付けて下さい。
javascript:'use strict';(async function(){var b=Array.from(document.querySelectorAll("#highlight")).map(a=>a.textContent).join("\n");navigator.clipboard.writeText(b);console.log("copied")})();
  1. Kindleのハイライトのページを開いたら、1で保存したブックマークをクリックします。すると、ハイライトの内容がクリップボードに保存されます。

ブックマークレットを編集したい場合

  • 以下のコードを下敷きに、編集 → Closure Compiler でコンパイル。詳しくはここを見て下さい。
// ==ClosureCompiler==
// @output_file_name default.js
// @compilation_level SIMPLE_OPTIMIZATIONS
// @language_out ECMASCRIPT_2017
// ==/ClosureCompiler==
javascript:(async function() {
  var t = Array.from(document.querySelectorAll('#highlight')).map(v => v.textContent).join("\n")
  
  // If you want to specify the color of the highlight use below.
  // var t = Array.from(document.querySelectorAll('.kp-notebook-highlight-yellow')).map(v => v.textContent.trim()).join("\n")
  
  navigator.clipboard.writeText(t)
  console.log("copied");
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment