ソース
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"));
})();
実行結果
Googleカレンダーのこういう画面でブックマークレットを起動すると、以下のような文字列がクリップボードにコピーされる。
9月 20日 (土曜日) 11:00~12:00
9月 21日 (日曜日) 11:00~12:00, 13:00~14:00