6
5

More than 5 years have passed since last update.

Kindleでハイライトした内容をScrapboxに書き込むためのメモ

Posted at
  • Kindle Notebookを開く
  • ブックマークに追加して、編集のURLに以下のJavaScriptコードをコピペする
    • your-project-nameを自分のScrapboxのプロジェクト名に変更する
ブックマークレット
 javascript:
Scrapbox="https://scrapbox.io/your-project-name/";
url="https://read.amazon.co.jp/kp/notebook";
if(location.href.indexOf(url) == 0) {
  var titleElement=document.getElementById("annotation-scroller").querySelectorAll("h3.kp-notebook-metadata");
  var title =titleElement[0].innerText;

  var authorElement=document.getElementById("annotation-scroller").querySelectorAll(".a-spacing-none");
  var authors = authorElement[0].innerText;  
  var content ="";

  var highlightNodes = document.getElementsByClassName("kp-notebook-highlight");
  var highlights = [];

  var quotationNodes = document.querySelectorAll("#annotationHighlightHeader");
  var quotationPages = [];

  for (var i = 0; i < highlightNodes.length; i++) {
    highlights.push(highlightNodes[i].innerText);
  }

  for (var i = 0; i < quotationNodes.length; i++) {
    quotationPages.push(quotationNodes[i].innerText);
  }

  var banner = "[" + document.querySelector(".kp-notebook-printable img").src + " " + document.querySelector(".kp-notebook-printable").href + "]";  
  content += banner;
  content += "\n";
  content += "By: " + authors;  
  content += "\n\n";

  for(var i = 0; i < quotationPages.length; i++) {
    content += quotationPages[i];
    content += "\n";
    content += ">" + highlights[i];
    content += "\n";
  }

  var links = "#readings" + " ";  
  authorList = authors.split('');
  for (var i = 0; i < authorList.length; i++) {
    links += "#" + authorList[i] + " ";
  }
  content += links;

  url = Scrapbox + encodeURIComponent(title) + "?body=" + encodeURIComponent(content);
}

location = url;

Scrapboxに追加したい本を選択して、ブックマークをクリックすると自動的にScrapboxに追加される。

参考

W&R : Jazzと読書の日々

6
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
5