0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Googleカレンダーの検索結果をクリップボードにコピーするブックマークレット

Posted at

ソース

javascript: (function() {
  const getNodesByXPath = (xpath,doc) => {
    const result = document.evaluate(
        xpath,
        doc,
        null,
        XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,
        null
    );
    return [...Array(result.snapshotLength)].map((_, i) => result.snapshotItem(i));
  };
  let lines = [];
  document.querySelectorAll('div[role=rowgroup]').forEach(row => {
    let mda = row.querySelector('[aria-label]').getAttributeNode("aria-label").value;
    let time_nodes = getNodesByXPath(".//*[contains(text(),'~')]",row);
    let time_range =time_nodes.map(ele => ele.textContent).join(', ');
    lines.push(mda + " " + time_range);
  });
  navigator.clipboard.writeText(lines.join("\n"));
})();

実行結果

image.png

Googleカレンダーのこういう画面でブックマークレットを起動すると、以下のような文字列がクリップボードにコピーされる。

9月 20日 (土曜日) 11:00~12:00
9月 21日 (日曜日) 11:00~12:00, 13:00~14:00
0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?