I use Google calendar for managing my schedule. But there is no approach to getting all events in text format. So I wrote this for obtaining events from Google Calendar.
- open Google Calendar within chrome.
- press F12 to open dev tool.
- click console tab.
- copy and paste this code below.
var list = document.querySelectorAll('div[role="gridcell"]');
const BEGIN_NO_EVS_EN = 'No events';
const BEGIN_NO_EVS_ZH = '没有活动';
console.log(list.length);
list.forEach(function(item, index) {
if (!item.innerText.startsWith(BEGIN_NO_EVS_EN) && !item.innerText.startsWith(BEGIN_NO_EVS_ZH)) {
let arr = item.innerText.split('\n');
if(arr.length>=3){
arr.forEach(function(itemOfArr, indexOfArr) {
let eventInfo = itemOfArr.split(', ')
if(indexOfArr>=2 && eventInfo.length>2){
console.log(eventInfo[4] + ' ' +eventInfo[1]);
}
});
}
}
});
And then all events will show on chrome.
I must tell you that this script only supports English and Chinese set in your Google Calendar. Searching HTML doms is the way I use it. So this script may not work well in the future.