diff --git a/src/content/google-calendar.js b/src/content/google-calendar.js index c959c1d19..99885c74f 100644 --- a/src/content/google-calendar.js +++ b/src/content/google-calendar.js @@ -1,3 +1,8 @@ +/** + * @name Google Calendar + * @urlAlias calendar.google.com + * @urlRegex *://calendar.google.com/* + */ 'use strict'; /* global $, togglbutton */ @@ -38,23 +43,31 @@ togglbutton.render(rootLevelSelectors, { observe: true }, elem => { return; } - const closeButton = $('[aria-label]:first-child', elem); + const closeButton = $('[aria-label="Close"]:first-child', elem); getDescription = () => { const titleSpan = $('span[role="heading"]', elem); return titleSpan ? titleSpan.textContent.trim() : ''; }; target = closeButton.parentElement.parentElement.nextSibling; // Left of the left-most action + if(target.hasAttribute('data-dragsource-type')) { + // This happens for event creation + target = null + } } else if (elemIsDetail) { - const closeButton = $('div[aria-label]', elem); + const closeButton = $('[aria-label^="Cancel event"]', elem); getDescription = () => { const titleInput = $('input[data-initial-value]', elem); return titleInput ? titleInput.value.trim() : ''; }; target = - closeButton.parentElement.nextElementSibling.lastElementChild - .lastElementChild; // Date(s)/All day section + closeButton + .parentElement + .parentElement + .parentElement + .parentElement + .nextElementSibling.lastElementChild.lastElementChild; // Date(s)/All day section } if (!target || target.tagName.toLowerCase() !== 'div') { diff --git a/src/origins.js b/src/origins.js index 9565e839e..f1d4f1534 100644 --- a/src/origins.js +++ b/src/origins.js @@ -252,7 +252,8 @@ export default { }, 'calendar.google.com': { url: '*://calendar.google.com/*', - name: 'Google Calendar' + name: 'Google Calendar', + file: 'google-calendar.js' }, 'classroom.google.com': { url: '*://classroom.google.com/*',