@inboxsdk/core 1.2.4 → 1.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/inboxsdk.js +4474 -463
- package/inboxsdk.js.map +1 -1
- package/package.json +1 -1
- package/pageWorld.js +1 -1
- package/pageWorld.js.map +1 -1
- package/src/common/load-script.d.ts +0 -6
- package/src/common/load-script.d.ts.map +1 -1
- package/src/inboxsdk-js/loading/platform-implementation-loader.d.ts.map +1 -1
- package/src/inboxsdk.d.ts +29 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/add-nav-item.d.ts +2 -2
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/add-nav-item.d.ts.map +1 -1
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/isIntegratedViewGmail.d.ts +6 -1
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/isIntegratedViewGmail.d.ts.map +1 -1
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver.d.ts +2 -2
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver.d.ts.map +1 -1
- package/src/platform-implementation-js/dom-driver/gmail/gmail-element-getter.d.ts +5 -0
- package/src/platform-implementation-js/dom-driver/gmail/gmail-element-getter.d.ts.map +1 -1
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-attachment-card-view.d.ts +13 -5
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-attachment-card-view.d.ts.map +1 -1
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-nav-item-view.d.ts +1 -1
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-nav-item-view.d.ts.map +1 -1
- package/src/platform-implementation-js/lib/inject-script-EMBEDDED.d.ts.map +1 -1
- package/src/platform-implementation-js/namespaces/conversations.d.ts +7 -0
- package/src/platform-implementation-js/namespaces/conversations.d.ts.map +1 -1
- package/src/platform-implementation-js/namespaces/nav-menu.d.ts +4 -2
- package/src/platform-implementation-js/namespaces/nav-menu.d.ts.map +1 -1
- package/src/platform-implementation-js/views/conversations/attachment-card-view.d.ts +12 -5
- package/src/platform-implementation-js/views/conversations/attachment-card-view.d.ts.map +1 -1
- package/src/platform-implementation-js/views/native-nav-item-view.d.ts +2 -1
- package/src/platform-implementation-js/views/native-nav-item-view.d.ts.map +1 -1
- package/src/build/exec.js +0 -26
- package/src/build/spawn.js +0 -17
- package/src/common/ajax.js +0 -90
- package/src/common/cachebust-url.js +0 -10
- package/src/common/censorHTMLstring.js +0 -37
- package/src/common/censorHTMLtree.js +0 -28
- package/src/common/censorJSONTree.js +0 -15
- package/src/common/connectivity-test.js +0 -21
- package/src/common/defer.js +0 -11
- package/src/common/find-parent.js +0 -10
- package/src/common/get-extension-id.js +0 -7
- package/src/common/get-or-fail.js +0 -8
- package/src/common/get-session-id.js +0 -14
- package/src/common/get-stack-trace.js +0 -6
- package/src/common/html-to-text.js +0 -7
- package/src/common/isElementVisible.js +0 -6
- package/src/common/load-script.js +0 -128
- package/src/common/log-error.js +0 -185
- package/src/common/quoted-split.js +0 -18
- package/src/common/rate-limit-queuer.js +0 -57
- package/src/common/rate-limit.js +0 -14
- package/src/common/version.js +0 -8
- package/src/inboxsdk-js/header.js +0 -19
- package/src/inboxsdk-js/inboxsdk-NONREMOTE-INTEGRATED-PAGEWORLD.js +0 -4
- package/src/inboxsdk-js/inboxsdk-NONREMOTE.js +0 -4
- package/src/inboxsdk-js/inboxsdk-REMOTE.js +0 -2
- package/src/inboxsdk-js/inboxsdk-TEST.js +0 -5
- package/src/inboxsdk-js/inboxsdk.js +0 -23
- package/src/inboxsdk-js/loading/load-platform-implementation-DEV.js +0 -14
- package/src/inboxsdk-js/loading/platform-implementation-loader.js +0 -31
- package/src/injected-js/gmail/constants.js +0 -2
- package/src/injected-js/gmail/modify-suggestions.js +0 -106
- package/src/injected-js/gmail/setup-gmail-interceptor.js +0 -936
- package/src/injected-js/gmail/setup-gmonkey-handler.js +0 -49
- package/src/injected-js/gmail/sync-compose-processor-20220909.js +0 -298
- package/src/injected-js/gmail/sync-compose-processor.js +0 -55
- package/src/injected-js/gmail/sync-compose-request-processor.js +0 -109
- package/src/injected-js/gmail/thread-identifier/click-and-get-popup-url.js +0 -71
- package/src/injected-js/gmail/thread-identifier/index.js +0 -133
- package/src/injected-js/gmail/thread-identifier/thread-row-parser.js +0 -61
- package/src/injected-js/injected-logger.js +0 -50
- package/src/injected-js/main.js +0 -49
- package/src/injected-js/message-metadata-holder.js +0 -103
- package/src/injected-js/setup-data-exposer.js +0 -135
- package/src/injected-js/setup-error-silencer.js +0 -15
- package/src/injected-js/setup-event-reemitter.js +0 -47
- package/src/injected-js/setupCustomViewEventAssassin.js +0 -90
- package/src/injected-js/setupInboxCustomViewLinkFixer.js +0 -24
- package/src/injected-js/setupPushStateListener.js +0 -14
- package/src/injected-js/xhr-helper.js +0 -43
- package/src/injected-js/xhr-proxy-factory.js +0 -537
- package/src/platform-implementation-js/constants/nav-item-types.js +0 -19
- package/src/platform-implementation-js/constants/router.js +0 -60
- package/src/platform-implementation-js/constants/toolbars.js +0 -5
- package/src/platform-implementation-js/dom-driver/gmail/gmail-butter-bar-driver.js +0 -158
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/add-app-menu-item.js +0 -20
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/add-collapsible-panel.js +0 -38
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/add-nav-item.js +0 -98
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/add-support-item.js +0 -4
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/add-toolbar-button-for-app.js +0 -14
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/create-link.js +0 -60
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/encodeDraftUrlId.js +0 -8
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/get-draft-id-for-message-id.js +0 -47
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/get-native-nav-item.js +0 -31
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/get-rfc-message-id-for-gmail-message-id.js +0 -12
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/get-rfc-message-id-for-gmail-thread-id.js +0 -33
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/get-url-object.js +0 -22
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/getSyncThreadForOldGmailThreadId.js +0 -18
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/getSyncThreadFromSyncThreadId.js +0 -57
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/gmail-load-event.js +0 -40
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/goto-view.js +0 -55
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/isIntegratedViewGmail.js +0 -14
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/keyboard-shortcut-help-modifier.js +0 -177
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/open-compose-window.js +0 -17
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/open-draft-by-message-id.js +0 -44
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/override-gmail-back-button.js +0 -49
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/register-search-query-rewriter.js +0 -18
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/register-search-suggestions-provider.js +0 -138
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/setup-compose-view-driver-stream.js +0 -112
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/setup-route-view-driver-stream.js +0 -152
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/show-app-id-warning.js +0 -21
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/show-custom-route-view.js +0 -48
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/show-custom-thread-list.js +0 -357
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/show-native-route-view.js +0 -19
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/suppressAddon.js +0 -36
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/temporary-track-download-url-validity.js +0 -36
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/thread-row-identifier.js +0 -85
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/track-events.js +0 -142
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/track-gmail-styles.js +0 -115
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver/user-info.js +0 -50
- package/src/platform-implementation-js/dom-driver/gmail/gmail-driver.js +0 -723
- package/src/platform-implementation-js/dom-driver/gmail/gmail-element-getter/get-main-content-element-changed-stream.js +0 -38
- package/src/platform-implementation-js/dom-driver/gmail/gmail-element-getter/wait-for-gmail-mode-to-settle.js +0 -12
- package/src/platform-implementation-js/dom-driver/gmail/gmail-element-getter.js +0 -264
- package/src/platform-implementation-js/dom-driver/gmail/gmail-page-communicator.js +0 -201
- package/src/platform-implementation-js/dom-driver/gmail/gmail-response-processor.js +0 -532
- package/src/platform-implementation-js/dom-driver/gmail/gmail-sync-response-processor.js +0 -300
- package/src/platform-implementation-js/dom-driver/gmail/is-compose-titlebar-light-color.js +0 -21
- package/src/platform-implementation-js/dom-driver/gmail/make-xhr-interceptor.js +0 -92
- package/src/platform-implementation-js/dom-driver/gmail/makePageParserTree.js +0 -28
- package/src/platform-implementation-js/dom-driver/gmail/pageParserOptions.js +0 -19
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-app-menu-item-view.js +0 -129
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-app-sidebar-view/index.js +0 -80
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-app-sidebar-view/primary/add-companion-global-icon-area.js +0 -23
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-app-sidebar-view/primary/add-companion-thread-icon-area.js +0 -26
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-app-sidebar-view/primary/add-to-icon-area.js +0 -16
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-app-sidebar-view/primary/index.js +0 -723
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-app-toolbar-button-view/monitor-top-banner-size-and-react.js +0 -24
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-app-toolbar-button-view.js +0 -172
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-attachment-area-view.js +0 -106
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-attachment-card-view.js +0 -328
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-backdrop.js +0 -22
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-collapsible-section-view.js +0 -720
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/add-button.js +0 -135
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/add-compose-notice.js +0 -50
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/add-recipient-row.js +0 -65
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/add-status-bar.js +0 -101
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/add-tooltip-to-button.js +0 -66
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/detectClassicRecipientsArea.js +0 -38
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/ensure-app-button-toolbars-are-closed.js +0 -10
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/ensure-grouping-is-open.js +0 -14
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/focus.js +0 -13
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/from-manager.js +0 -60
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/get-additional-action-toolbar.js +0 -54
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/get-address-changes-stream.js +0 -98
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/get-address-information-extractor.js +0 -28
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/get-body-changes-stream.js +0 -13
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/get-formatting-area-offset-left.js +0 -18
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/get-minimized-stream.js +0 -16
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/get-recipients.js +0 -22
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/get-response-type-changes-stream.js +0 -23
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/gmail-compose-button-view.js +0 -233
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/insert-link-into-body.js +0 -19
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/manage-button-grouping.js +0 -355
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/monitor-selection-range.js +0 -21
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/override-edit-subject.js +0 -63
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/page-parser.js +0 -223
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/position-formatting-toolbar.js +0 -19
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/set-recipients.js +0 -157
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/setupLinkPopovers.js +0 -109
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/size-fixer.js +0 -123
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view/update-insert-more-area-left.js +0 -16
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-compose-view.js +0 -1542
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-message-view/attachment-icon.js +0 -4
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-message-view/get-updated-contact.js +0 -75
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-message-view.js +0 -737
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-nav-item-view.js +0 -763
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-route-view/gmail-route-processor.js +0 -103
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-route-view/gmail-route-view.js +0 -508
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-row-list-view.js +0 -236
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-support-item-view.js +0 -84
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-thread-row-view.js +0 -986
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-thread-view/width-manager.js +0 -26
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-thread-view.js +0 -658
- package/src/platform-implementation-js/dom-driver/gmail/views/gmail-toolbar-view.js +0 -459
- package/src/platform-implementation-js/dom-driver/gmail/views/native-gmail-nav-item-view.js +0 -265
- package/src/platform-implementation-js/dom-driver/gmail/widgets/buttons/button-color-classes.js +0 -33
- package/src/platform-implementation-js/dom-driver/gmail/widgets/buttons/button-view.js +0 -325
- package/src/platform-implementation-js/dom-driver/gmail/widgets/buttons/create-accessory-button-view.js +0 -61
- package/src/platform-implementation-js/dom-driver/gmail/widgets/buttons/create-parent-accessory-button-view.js +0 -58
- package/src/platform-implementation-js/dom-driver/gmail/widgets/buttons/inbox-dropdown-button-view.js +0 -23
- package/src/platform-implementation-js/dom-driver/gmail/widgets/buttons/modal-button-view.js +0 -101
- package/src/platform-implementation-js/dom-driver/gmail/widgets/buttons/more-dropdown-button-view.js +0 -30
- package/src/platform-implementation-js/dom-driver/gmail/widgets/buttons/more-parent-accessory-button-view.js +0 -10
- package/src/platform-implementation-js/dom-driver/gmail/widgets/gmail-action-button-view.js +0 -42
- package/src/platform-implementation-js/dom-driver/gmail/widgets/gmail-dropdown-view.js +0 -22
- package/src/platform-implementation-js/dom-driver/gmail/widgets/gmail-label-view.js +0 -112
- package/src/platform-implementation-js/dom-driver/gmail/widgets/gmail-modal-view-driver.js +0 -122
- package/src/platform-implementation-js/dom-driver/gmail/widgets/gmail-mole-view-driver.js +0 -194
- package/src/platform-implementation-js/dom-driver/gmail/widgets/gmail-tooltip-view.js +0 -352
- package/src/platform-implementation-js/dom-driver/gmail/widgets/gmail-top-message-bar-driver.js +0 -76
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-backdrop.js +0 -57
- package/src/platform-implementation-js/dom-driver/inbox/views/inbox-drawer-view.js +0 -291
- package/src/platform-implementation-js/driver-common/compose/getDiscardStream.js +0 -28
- package/src/platform-implementation-js/driver-common/compose/getPresendingStream.js +0 -46
- package/src/platform-implementation-js/driver-common/getAccountUrlPart.js +0 -17
- package/src/platform-implementation-js/driver-common/getGmailMessageIdForSyncMessageId.js +0 -17
- package/src/platform-implementation-js/driver-common/getGmailThreadIdForRfcMessageId.js +0 -44
- package/src/platform-implementation-js/driver-common/getOriginalMessagePage.js +0 -33
- package/src/platform-implementation-js/driver-common/getRfcMessageIdForSyncMessageId.js +0 -18
- package/src/platform-implementation-js/driver-common/getSyncThreadsForSearch.js +0 -49
- package/src/platform-implementation-js/driver-common/getThreadIdFromMessageId.js +0 -13
- package/src/platform-implementation-js/driver-common/gmailAjax.js +0 -65
- package/src/platform-implementation-js/driver-common/inboxAjax.js +0 -5
- package/src/platform-implementation-js/driver-common/render-custom-icon.js +0 -16
- package/src/platform-implementation-js/driver-common/requestGmailThread.js +0 -24
- package/src/platform-implementation-js/driver-common/sidebar/AppSidebar.js +0 -245
- package/src/platform-implementation-js/driver-common/sidebar/ContentPanelViewDriver.js +0 -144
- package/src/platform-implementation-js/driver-common/sidebar/constants.js +0 -26
- package/src/platform-implementation-js/driver-common/update-icon.js +0 -90
- package/src/platform-implementation-js/driver-interfaces/compose-view-driver.js +0 -1
- package/src/platform-implementation-js/driver-interfaces/driver.js +0 -1
- package/src/platform-implementation-js/driver-interfaces/mole-view-driver.js +0 -1
- package/src/platform-implementation-js/driver-interfaces/route-view-driver.js +0 -1
- package/src/platform-implementation-js/lib/ErrorCollector.js +0 -47
- package/src/platform-implementation-js/lib/Membrane.js +0 -22
- package/src/platform-implementation-js/lib/ScrollableContainByScreen.js +0 -30
- package/src/platform-implementation-js/lib/attemptWithRetries.js +0 -16
- package/src/platform-implementation-js/lib/common-page-communicator.js +0 -137
- package/src/platform-implementation-js/lib/copyAndValidateAutocompleteResults.js +0 -35
- package/src/platform-implementation-js/lib/css-selector-escape.js +0 -6
- package/src/platform-implementation-js/lib/delay-asap.js +0 -10
- package/src/platform-implementation-js/lib/delay-idle.js +0 -16
- package/src/platform-implementation-js/lib/dom/block-and-reemit-keyboard-events.js +0 -36
- package/src/platform-implementation-js/lib/dom/custom-events.js +0 -5
- package/src/platform-implementation-js/lib/dom/element-view-mapper.js +0 -9
- package/src/platform-implementation-js/lib/dom/generic-button-view.js +0 -39
- package/src/platform-implementation-js/lib/dom/get-insert-before-element.js +0 -39
- package/src/platform-implementation-js/lib/dom/get-selection.js +0 -30
- package/src/platform-implementation-js/lib/dom/insert-element-in-order.js +0 -38
- package/src/platform-implementation-js/lib/dom/insert-html-at-cursor.js +0 -83
- package/src/platform-implementation-js/lib/dom/is-node-in-range.js +0 -12
- package/src/platform-implementation-js/lib/dom/keyboard-shortcut-stream.js +0 -12
- package/src/platform-implementation-js/lib/dom/make-element-child-stream.js +0 -79
- package/src/platform-implementation-js/lib/dom/make-element-stream-merger.js +0 -27
- package/src/platform-implementation-js/lib/dom/make-element-view-stream.js +0 -15
- package/src/platform-implementation-js/lib/dom/make-mutation-observer-chunked-stream.js +0 -15
- package/src/platform-implementation-js/lib/dom/make-mutation-observer-stream.js +0 -5
- package/src/platform-implementation-js/lib/dom/on-mouse-down-and-up.js +0 -8
- package/src/platform-implementation-js/lib/dom/outsideClicksAndEscape.js +0 -38
- package/src/platform-implementation-js/lib/dom/parentNodes.js +0 -8
- package/src/platform-implementation-js/lib/dom/querySelectorOrFail.js +0 -6
- package/src/platform-implementation-js/lib/dom/reemitClickEventForReact.js +0 -22
- package/src/platform-implementation-js/lib/dom/set-css.js +0 -20
- package/src/platform-implementation-js/lib/dom/simulate-drag-and-drop.js +0 -88
- package/src/platform-implementation-js/lib/dom/simulate-key.js +0 -46
- package/src/platform-implementation-js/lib/dom/simulate-mouse-event.js +0 -16
- package/src/platform-implementation-js/lib/dom/trigger-relay-event.js +0 -7
- package/src/platform-implementation-js/lib/extract-contact-from-email-contact-string.js +0 -25
- package/src/platform-implementation-js/lib/fake-window-resize.js +0 -5
- package/src/platform-implementation-js/lib/from-event-target-capture.js +0 -12
- package/src/platform-implementation-js/lib/fromEventsWithOptions.js +0 -10
- package/src/platform-implementation-js/lib/handle-compose-link-chips.js +0 -124
- package/src/platform-implementation-js/lib/handler-registry.js +0 -67
- package/src/platform-implementation-js/lib/idMap.js +0 -40
- package/src/platform-implementation-js/lib/imageRequest.js +0 -8
- package/src/platform-implementation-js/lib/incrementName.js +0 -7
- package/src/platform-implementation-js/lib/inject-script-EMBEDDED.js +0 -8
- package/src/platform-implementation-js/lib/inject-script.js +0 -33
- package/src/platform-implementation-js/lib/insert-link-chip-into-body.js +0 -44
- package/src/platform-implementation-js/lib/is-valid-app-id.js +0 -27
- package/src/platform-implementation-js/lib/is-valid-email.js +0 -14
- package/src/platform-implementation-js/lib/isNotNil.js +0 -5
- package/src/platform-implementation-js/lib/isStreakAppId.js +0 -11
- package/src/platform-implementation-js/lib/logger.js +0 -439
- package/src/platform-implementation-js/lib/parseParamsFromRouteID.js +0 -10
- package/src/platform-implementation-js/lib/persistent-queue.js +0 -107
- package/src/platform-implementation-js/lib/populateRouteID.js +0 -17
- package/src/platform-implementation-js/lib/react/ElementContainer.js +0 -26
- package/src/platform-implementation-js/lib/routeIDmatchesHash.js +0 -8
- package/src/platform-implementation-js/lib/safe-event-emitter.js +0 -16
- package/src/platform-implementation-js/lib/stopper-pool.js +0 -41
- package/src/platform-implementation-js/lib/stream-wait-for.js +0 -30
- package/src/platform-implementation-js/lib/toItemWithLifetimeStream.js +0 -12
- package/src/platform-implementation-js/lib/toLiveSet.js +0 -22
- package/src/platform-implementation-js/lib/wait-for.js +0 -38
- package/src/platform-implementation-js/lib/waitForAsync.js +0 -18
- package/src/platform-implementation-js/main-INTEGRATED-PAGEWORLD.js +0 -5
- package/src/platform-implementation-js/main.js +0 -42
- package/src/platform-implementation-js/namespaces/app-menu.js +0 -81
- package/src/platform-implementation-js/namespaces/butter-bar.js +0 -163
- package/src/platform-implementation-js/namespaces/compose.js +0 -59
- package/src/platform-implementation-js/namespaces/conversations.js +0 -83
- package/src/platform-implementation-js/namespaces/global.js +0 -30
- package/src/platform-implementation-js/namespaces/keyboard.js +0 -30
- package/src/platform-implementation-js/namespaces/lists.js +0 -40
- package/src/platform-implementation-js/namespaces/modal.js +0 -43
- package/src/platform-implementation-js/namespaces/nav-menu.js +0 -33
- package/src/platform-implementation-js/namespaces/router.js +0 -139
- package/src/platform-implementation-js/namespaces/search.js +0 -29
- package/src/platform-implementation-js/namespaces/toolbars.js +0 -147
- package/src/platform-implementation-js/namespaces/user.js +0 -57
- package/src/platform-implementation-js/namespaces/widgets.js +0 -73
- package/src/platform-implementation-js/platform-implementation.js +0 -178
- package/src/platform-implementation-js/views/SimpleElementView.js +0 -16
- package/src/platform-implementation-js/views/app-menu-item-view.js +0 -442
- package/src/platform-implementation-js/views/app-toolbar-button-view.js +0 -43
- package/src/platform-implementation-js/views/collapsible-panel-view.js +0 -256
- package/src/platform-implementation-js/views/collapsible-section-view.js +0 -63
- package/src/platform-implementation-js/views/compose-button-view.js +0 -45
- package/src/platform-implementation-js/views/compose-view.js +0 -310
- package/src/platform-implementation-js/views/content-panel-view.js +0 -36
- package/src/platform-implementation-js/views/conversations/attachment-card-view.js +0 -41
- package/src/platform-implementation-js/views/conversations/custom-message-view.js +0 -117
- package/src/platform-implementation-js/views/conversations/message-view.js +0 -203
- package/src/platform-implementation-js/views/conversations/thread-view.js +0 -97
- package/src/platform-implementation-js/views/keyboard-shortcut-handle.js +0 -14
- package/src/platform-implementation-js/views/native-nav-item-view.js +0 -60
- package/src/platform-implementation-js/views/nav-item-view.js +0 -130
- package/src/platform-implementation-js/views/route-view/custom-route-view.js +0 -25
- package/src/platform-implementation-js/views/route-view/dummy-route-view-driver.js +0 -29
- package/src/platform-implementation-js/views/route-view/list-route-view.js +0 -46
- package/src/platform-implementation-js/views/route-view/route-view.js +0 -47
- package/src/platform-implementation-js/views/section-view.js +0 -60
- package/src/platform-implementation-js/views/thread-row-view.js +0 -90
- package/src/platform-implementation-js/widgets/buttons/basic-button-view-controller.js +0 -39
- package/src/platform-implementation-js/widgets/buttons/dropdown-button-view-controller.js +0 -98
- package/src/platform-implementation-js/widgets/buttons/dropdown-view.js +0 -121
- package/src/platform-implementation-js/widgets/drawer-view.js +0 -46
- package/src/platform-implementation-js/widgets/modal-view.js +0 -108
- package/src/platform-implementation-js/widgets/mole-view.js +0 -38
- package/src/platform-implementation-js/widgets/top-message-bar-view.js +0 -15
|
@@ -1,936 +0,0 @@
|
|
|
1
|
-
import clone from 'lodash/clone';
|
|
2
|
-
import flatten from 'lodash/flatten';
|
|
3
|
-
import find from 'lodash/find';
|
|
4
|
-
import intersection from 'lodash/intersection';
|
|
5
|
-
import includes from 'lodash/includes';
|
|
6
|
-
import BigNumber from 'bignumber.js';
|
|
7
|
-
import Kefir from 'kefir';
|
|
8
|
-
import * as logger from '../injected-logger';
|
|
9
|
-
import XHRProxyFactory from '../xhr-proxy-factory';
|
|
10
|
-
import querystring, { stringify } from 'querystring';
|
|
11
|
-
import * as threadIdentifier from './thread-identifier';
|
|
12
|
-
import * as messageMetadataHolder from '../message-metadata-holder';
|
|
13
|
-
import * as GmailResponseProcessor from '../../platform-implementation-js/dom-driver/gmail/gmail-response-processor';
|
|
14
|
-
import * as GmailSyncResponseProcessor from '../../platform-implementation-js/dom-driver/gmail/gmail-sync-response-processor';
|
|
15
|
-
import quotedSplit from '../../common/quoted-split';
|
|
16
|
-
import defer from '../../common/defer';
|
|
17
|
-
import modifySuggestions from './modify-suggestions';
|
|
18
|
-
import { parseComposeRequestBody, parseComposeResponseBody, replaceBodyContentInComposeSendRequestBody, } from './sync-compose-processor';
|
|
19
|
-
function logErrorExceptEventListeners(err, details) {
|
|
20
|
-
// Don't log Gmail's errors
|
|
21
|
-
if (details !== 'XMLHttpRequest event listener error') {
|
|
22
|
-
logger.error(err, details);
|
|
23
|
-
}
|
|
24
|
-
else {
|
|
25
|
-
setTimeout(function () {
|
|
26
|
-
// let window.onerror log this
|
|
27
|
-
throw err;
|
|
28
|
-
}, 1);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
export default function setupGmailInterceptor() {
|
|
32
|
-
let jsFrame = null;
|
|
33
|
-
const js_frame_element = top.document.getElementById('js_frame');
|
|
34
|
-
if (js_frame_element) {
|
|
35
|
-
jsFrame = js_frame_element.contentDocument.defaultView;
|
|
36
|
-
}
|
|
37
|
-
else {
|
|
38
|
-
logger.eventSdkPassive('noJSFrameElementFound');
|
|
39
|
-
}
|
|
40
|
-
setupGmailInterceptorOnFrames(window, jsFrame);
|
|
41
|
-
}
|
|
42
|
-
// Split into a separate step to make it easy for tests to use.
|
|
43
|
-
export function setupGmailInterceptorOnFrames(mainFrame, jsFrame) {
|
|
44
|
-
const main_wrappers = [], js_frame_wrappers = [];
|
|
45
|
-
{
|
|
46
|
-
const main_originalXHR = mainFrame.XMLHttpRequest;
|
|
47
|
-
mainFrame.XMLHttpRequest = XHRProxyFactory(main_originalXHR, main_wrappers, {
|
|
48
|
-
logError: logErrorExceptEventListeners,
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
if (jsFrame) {
|
|
52
|
-
const js_frame_originalXHR = jsFrame.XMLHttpRequest;
|
|
53
|
-
jsFrame.XMLHttpRequest = XHRProxyFactory(js_frame_originalXHR, js_frame_wrappers, {
|
|
54
|
-
logError: logErrorExceptEventListeners,
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
threadIdentifier.setup();
|
|
58
|
-
messageMetadataHolder.setup();
|
|
59
|
-
//email sending modifier/notifier
|
|
60
|
-
{
|
|
61
|
-
const modifiers = {};
|
|
62
|
-
Kefir.fromEvents(document, 'inboxSDKregisterComposeRequestModifier').onValue(({ detail }) => {
|
|
63
|
-
const keyId = detail.composeid || detail.draftID;
|
|
64
|
-
if (!modifiers[keyId]) {
|
|
65
|
-
modifiers[keyId] = [];
|
|
66
|
-
}
|
|
67
|
-
modifiers[keyId].push(detail.modifierId);
|
|
68
|
-
});
|
|
69
|
-
Kefir.fromEvents(document, 'inboxSDKunregisterComposeRequestModifier').onValue(({ detail }) => {
|
|
70
|
-
const { keyId, modifierId } = detail;
|
|
71
|
-
modifiers[keyId] = modifiers[keyId].filter((item) => item !== modifierId);
|
|
72
|
-
if (modifiers[keyId].length === 0) {
|
|
73
|
-
delete modifiers[keyId];
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
js_frame_wrappers.push({
|
|
77
|
-
isRelevantTo: function (connection) {
|
|
78
|
-
return connection.params.act === 'sm';
|
|
79
|
-
},
|
|
80
|
-
originalSendBodyLogger: function (connection, body) {
|
|
81
|
-
triggerEvent({
|
|
82
|
-
type: 'emailSending',
|
|
83
|
-
body: body,
|
|
84
|
-
});
|
|
85
|
-
},
|
|
86
|
-
requestChanger: async function (connection, request) {
|
|
87
|
-
let composeParams = querystring.parse(request.body);
|
|
88
|
-
const composeid = composeParams.composeid;
|
|
89
|
-
const composeModifierIds = modifiers[composeParams.composeid];
|
|
90
|
-
if (!composeModifierIds || composeModifierIds.length === 0) {
|
|
91
|
-
return request;
|
|
92
|
-
}
|
|
93
|
-
for (let ii = 0; ii < composeModifierIds.length; ii++) {
|
|
94
|
-
const modifierId = composeModifierIds[ii];
|
|
95
|
-
const modificationPromise = Kefir.fromEvents(document, 'inboxSDKcomposeRequestModified')
|
|
96
|
-
.filter(({ detail }) => detail.composeid === composeid &&
|
|
97
|
-
detail.modifierId === modifierId)
|
|
98
|
-
.take(1)
|
|
99
|
-
.map(({ detail }) => detail.composeParams)
|
|
100
|
-
.toPromise( /* Promise */);
|
|
101
|
-
triggerEvent({
|
|
102
|
-
type: 'inboxSDKmodifyComposeRequest',
|
|
103
|
-
composeid,
|
|
104
|
-
modifierId,
|
|
105
|
-
composeParams: {
|
|
106
|
-
body: composeParams.body,
|
|
107
|
-
isPlainText: composeParams.ishtml !== '1',
|
|
108
|
-
},
|
|
109
|
-
});
|
|
110
|
-
const newComposeParams = await modificationPromise;
|
|
111
|
-
composeParams = Object.assign({}, composeParams, newComposeParams);
|
|
112
|
-
}
|
|
113
|
-
return Object.assign({}, request, {
|
|
114
|
-
body: stringifyComposeParams(composeParams),
|
|
115
|
-
});
|
|
116
|
-
},
|
|
117
|
-
afterListeners: function (connection) {
|
|
118
|
-
if (connection.status === 200) {
|
|
119
|
-
triggerEvent({
|
|
120
|
-
type: 'emailSent',
|
|
121
|
-
responseText: connection.originalResponseText,
|
|
122
|
-
originalSendBody: connection.originalSendBody,
|
|
123
|
-
});
|
|
124
|
-
if (connection.originalSendBody) {
|
|
125
|
-
const composeParams = querystring.parse(connection.originalSendBody);
|
|
126
|
-
delete modifiers[composeParams.composeid];
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
},
|
|
130
|
-
});
|
|
131
|
-
js_frame_wrappers.push({
|
|
132
|
-
isRelevantTo: function (connection) {
|
|
133
|
-
return connection.params.act === 'sd';
|
|
134
|
-
},
|
|
135
|
-
originalSendBodyLogger: function (connection, body) {
|
|
136
|
-
triggerEvent({
|
|
137
|
-
type: 'emailDraftSaveSending',
|
|
138
|
-
body: body,
|
|
139
|
-
});
|
|
140
|
-
},
|
|
141
|
-
afterListeners: function (connection) {
|
|
142
|
-
if (connection.status === 200) {
|
|
143
|
-
triggerEvent({
|
|
144
|
-
type: 'emailDraftReceived',
|
|
145
|
-
responseText: connection.originalResponseText,
|
|
146
|
-
originalSendBody: connection.originalSendBody,
|
|
147
|
-
connectionDetails: {
|
|
148
|
-
method: connection.method,
|
|
149
|
-
url: connection.url,
|
|
150
|
-
params: connection.params,
|
|
151
|
-
responseType: connection.responseType,
|
|
152
|
-
},
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
|
-
},
|
|
156
|
-
});
|
|
157
|
-
{
|
|
158
|
-
// Sync API-based compose sending intercept
|
|
159
|
-
const currentSendConnectionIDs = new WeakMap();
|
|
160
|
-
const currentDraftSaveConnectionIDs = new WeakMap();
|
|
161
|
-
const currentFirstDraftSaveConnectionIDs = new WeakMap();
|
|
162
|
-
main_wrappers.push({
|
|
163
|
-
isRelevantTo(connection) {
|
|
164
|
-
return /sync(?:\/u\/\d+)?\/i\/s/.test(connection.url);
|
|
165
|
-
},
|
|
166
|
-
originalSendBodyLogger(connection) {
|
|
167
|
-
if (connection.originalSendBody) {
|
|
168
|
-
const composeRequestDetails = parseComposeRequestBody(connection.originalSendBody);
|
|
169
|
-
if (!composeRequestDetails) {
|
|
170
|
-
return;
|
|
171
|
-
}
|
|
172
|
-
const { draftID } = composeRequestDetails;
|
|
173
|
-
switch (composeRequestDetails.type) {
|
|
174
|
-
case 'FIRST_DRAFT_SAVE':
|
|
175
|
-
currentFirstDraftSaveConnectionIDs.set(connection, draftID);
|
|
176
|
-
break;
|
|
177
|
-
case 'DRAFT_SAVE':
|
|
178
|
-
currentDraftSaveConnectionIDs.set(connection, draftID);
|
|
179
|
-
break;
|
|
180
|
-
case 'SEND':
|
|
181
|
-
currentSendConnectionIDs.set(connection, draftID);
|
|
182
|
-
triggerEvent({
|
|
183
|
-
type: 'emailSending',
|
|
184
|
-
draftID,
|
|
185
|
-
});
|
|
186
|
-
break;
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
},
|
|
190
|
-
requestChanger: async function (connection, request) {
|
|
191
|
-
const composeRequestDetails = parseComposeRequestBody(request.body);
|
|
192
|
-
if (!composeRequestDetails || composeRequestDetails.type !== 'SEND')
|
|
193
|
-
return request;
|
|
194
|
-
const { draftID } = composeRequestDetails;
|
|
195
|
-
const composeModifierIds = modifiers[draftID];
|
|
196
|
-
if (!composeModifierIds || composeModifierIds.length === 0)
|
|
197
|
-
return request;
|
|
198
|
-
let newEmailBody = composeRequestDetails.body;
|
|
199
|
-
for (let ii = 0; ii < composeModifierIds.length; ii++) {
|
|
200
|
-
const modifierId = composeModifierIds[ii];
|
|
201
|
-
const modificationPromise = Kefir.fromEvents(document, 'inboxSDKcomposeRequestModified')
|
|
202
|
-
.filter(({ detail }) => detail.draftID === draftID && detail.modifierId === modifierId)
|
|
203
|
-
.take(1)
|
|
204
|
-
.map(({ detail }) => detail.composeParams)
|
|
205
|
-
.toPromise( /* Promise */);
|
|
206
|
-
triggerEvent({
|
|
207
|
-
type: 'inboxSDKmodifyComposeRequest',
|
|
208
|
-
draftID,
|
|
209
|
-
modifierId,
|
|
210
|
-
composeParams: {
|
|
211
|
-
body: newEmailBody,
|
|
212
|
-
isPlainText: false,
|
|
213
|
-
},
|
|
214
|
-
});
|
|
215
|
-
const newComposeParams = await modificationPromise;
|
|
216
|
-
newEmailBody = newComposeParams.body;
|
|
217
|
-
}
|
|
218
|
-
return Object.assign({}, request, {
|
|
219
|
-
body: replaceBodyContentInComposeSendRequestBody(request.body, newEmailBody),
|
|
220
|
-
});
|
|
221
|
-
},
|
|
222
|
-
afterListeners(connection) {
|
|
223
|
-
if (currentSendConnectionIDs.has(connection) ||
|
|
224
|
-
currentDraftSaveConnectionIDs.has(connection) ||
|
|
225
|
-
currentFirstDraftSaveConnectionIDs.has(connection)) {
|
|
226
|
-
const sendFailed = () => {
|
|
227
|
-
triggerEvent({
|
|
228
|
-
type: 'emailSendFailed',
|
|
229
|
-
draftID,
|
|
230
|
-
});
|
|
231
|
-
currentSendConnectionIDs.delete(connection);
|
|
232
|
-
};
|
|
233
|
-
const draftID = currentSendConnectionIDs.get(connection) ||
|
|
234
|
-
currentDraftSaveConnectionIDs.get(connection) ||
|
|
235
|
-
currentFirstDraftSaveConnectionIDs.get(connection);
|
|
236
|
-
if (connection.status !== 200 || !connection.originalResponseText) {
|
|
237
|
-
sendFailed();
|
|
238
|
-
return;
|
|
239
|
-
}
|
|
240
|
-
try {
|
|
241
|
-
const responsesParsed = parseComposeResponseBody(connection.originalResponseText);
|
|
242
|
-
for (const responseParsed of responsesParsed) {
|
|
243
|
-
// If we're sending a draft, we only care about the response related to the draft we're sending.
|
|
244
|
-
if (draftID && !responseParsed.messageId.endsWith(draftID)) {
|
|
245
|
-
continue;
|
|
246
|
-
}
|
|
247
|
-
if (responseParsed.type === 'FIRST_DRAFT_SAVE' ||
|
|
248
|
-
responseParsed.type === 'DRAFT_SAVE') {
|
|
249
|
-
triggerEvent({
|
|
250
|
-
draftID: draftID,
|
|
251
|
-
type: 'emailDraftReceived',
|
|
252
|
-
rfcID: responseParsed.rfcID,
|
|
253
|
-
threadID: responseParsed.threadId,
|
|
254
|
-
messageID: responseParsed.messageId,
|
|
255
|
-
oldMessageID: responseParsed.oldMessageId,
|
|
256
|
-
oldThreadID: responseParsed.oldThreadId,
|
|
257
|
-
});
|
|
258
|
-
currentSendConnectionIDs.delete(connection);
|
|
259
|
-
currentDraftSaveConnectionIDs.delete(connection);
|
|
260
|
-
currentFirstDraftSaveConnectionIDs.delete(connection);
|
|
261
|
-
return;
|
|
262
|
-
}
|
|
263
|
-
else if (responseParsed.type === 'SEND') {
|
|
264
|
-
triggerEvent({
|
|
265
|
-
draftID: draftID,
|
|
266
|
-
type: 'emailSent',
|
|
267
|
-
rfcID: responseParsed.rfcID,
|
|
268
|
-
threadID: responseParsed.threadId,
|
|
269
|
-
messageID: responseParsed.messageId,
|
|
270
|
-
oldMessageID: responseParsed.oldMessageId,
|
|
271
|
-
oldThreadID: responseParsed.oldThreadId,
|
|
272
|
-
});
|
|
273
|
-
currentSendConnectionIDs.delete(connection);
|
|
274
|
-
currentDraftSaveConnectionIDs.delete(connection);
|
|
275
|
-
currentFirstDraftSaveConnectionIDs.delete(connection);
|
|
276
|
-
return;
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
catch (err) {
|
|
281
|
-
logger.eventSdkPassive('connection.requestResponseParsingFailed', {
|
|
282
|
-
responseParseError: err,
|
|
283
|
-
});
|
|
284
|
-
}
|
|
285
|
-
const originalResponse = JSON.parse(connection.originalResponseText);
|
|
286
|
-
// TODO this function silently fails way too easily. Need to add better logging for it!
|
|
287
|
-
if (currentFirstDraftSaveConnectionIDs.has(connection)) {
|
|
288
|
-
const wrapper = originalResponse[2] &&
|
|
289
|
-
originalResponse[2][6] &&
|
|
290
|
-
originalResponse[2][6][0] &&
|
|
291
|
-
originalResponse[2][6][0][1];
|
|
292
|
-
if (wrapper) {
|
|
293
|
-
const threadUpdate = wrapper[3] && wrapper[3][7] && wrapper[3][7][1];
|
|
294
|
-
const messageUpdate = threadUpdate && threadUpdate[5] && threadUpdate[5][0];
|
|
295
|
-
if (threadUpdate && messageUpdate) {
|
|
296
|
-
triggerEvent({
|
|
297
|
-
draftID: draftID,
|
|
298
|
-
type: 'emailDraftReceived',
|
|
299
|
-
rfcID: messageUpdate[14],
|
|
300
|
-
threadID: threadUpdate[4].split('|')[0],
|
|
301
|
-
messageID: messageUpdate[1],
|
|
302
|
-
oldMessageID: messageUpdate[56],
|
|
303
|
-
oldThreadID: threadUpdate[20],
|
|
304
|
-
});
|
|
305
|
-
}
|
|
306
|
-
else {
|
|
307
|
-
logger.error(new Error('Could not parse draft save'));
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
else {
|
|
311
|
-
// pre-2019-05-29 handling
|
|
312
|
-
logger.eventSdkPassive('old compose draft id handling hit');
|
|
313
|
-
const oldWrapper = originalResponse[2] &&
|
|
314
|
-
originalResponse[2][6] &&
|
|
315
|
-
originalResponse[2][6][1] &&
|
|
316
|
-
originalResponse[2][6][1][1];
|
|
317
|
-
if (oldWrapper) {
|
|
318
|
-
const saveUpdate = oldWrapper[3] && oldWrapper[3][1] && oldWrapper[3][1][1];
|
|
319
|
-
if (saveUpdate) {
|
|
320
|
-
triggerEvent({
|
|
321
|
-
draftID: draftID,
|
|
322
|
-
type: 'emailDraftReceived',
|
|
323
|
-
rfcID: saveUpdate[14],
|
|
324
|
-
messageID: saveUpdate[1],
|
|
325
|
-
oldMessageID: saveUpdate[48]
|
|
326
|
-
? new BigNumber(saveUpdate[48]).toString(16)
|
|
327
|
-
: saveUpdate[56],
|
|
328
|
-
syncThreadID: oldWrapper[1],
|
|
329
|
-
});
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
else {
|
|
335
|
-
const updateList = originalResponse[2]?.[6];
|
|
336
|
-
if (!updateList) {
|
|
337
|
-
sendFailed();
|
|
338
|
-
return;
|
|
339
|
-
}
|
|
340
|
-
const sendUpdateMatch = updateList.find((update) => update[1]?.[3]?.[7]?.[1]?.[5]?.[0]?.[14] &&
|
|
341
|
-
update[1][3][7][1][5].find((message) => includes(message[1], draftID)));
|
|
342
|
-
if (!sendUpdateMatch) {
|
|
343
|
-
if (currentSendConnectionIDs.has(connection)) {
|
|
344
|
-
const minimalSendUpdates = updateList.filter((update) => update[1]?.[3]?.[5]?.[3]);
|
|
345
|
-
if (minimalSendUpdates.length > 0) {
|
|
346
|
-
const threadID = minimalSendUpdates[0][1][1]
|
|
347
|
-
? minimalSendUpdates[0][1][1].replace(/\|.*$/, '')
|
|
348
|
-
: undefined;
|
|
349
|
-
triggerEvent({
|
|
350
|
-
draftID,
|
|
351
|
-
type: 'emailSent',
|
|
352
|
-
threadID,
|
|
353
|
-
//new compose
|
|
354
|
-
messageID: minimalSendUpdates[0][1][3]?.[5]?.[5]?.[0] || //replies
|
|
355
|
-
minimalSendUpdates[0][1][3][5][3]?.[0],
|
|
356
|
-
});
|
|
357
|
-
}
|
|
358
|
-
else {
|
|
359
|
-
sendFailed();
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
else {
|
|
363
|
-
sendFailed();
|
|
364
|
-
}
|
|
365
|
-
return;
|
|
366
|
-
}
|
|
367
|
-
const sendUpdateWrapper = sendUpdateMatch[1]?.[3]?.[7]?.[1];
|
|
368
|
-
const sendUpdate = sendUpdateWrapper[5].find((message) => message[1].includes(draftID));
|
|
369
|
-
if (!sendUpdate) {
|
|
370
|
-
sendFailed();
|
|
371
|
-
return;
|
|
372
|
-
}
|
|
373
|
-
const isEmailSentResponse = currentSendConnectionIDs.has(connection);
|
|
374
|
-
if (!Array.isArray(sendUpdate[11])) {
|
|
375
|
-
logger.error(new Error('sendUpdate[11] was not an array'));
|
|
376
|
-
}
|
|
377
|
-
else {
|
|
378
|
-
if (isEmailSentResponse) {
|
|
379
|
-
if (sendUpdate[11].indexOf('^r') >= 0) {
|
|
380
|
-
logger.error(new Error('sendUpdate[11] unexpectedly contained "^r"'));
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
}
|
|
384
|
-
if (isEmailSentResponse) {
|
|
385
|
-
if (sendUpdate[22] !== undefined && sendUpdate[22] !== 3) {
|
|
386
|
-
logger.error(new Error('sendUpdate[22] was not expected value'), {
|
|
387
|
-
value: sendUpdate[22],
|
|
388
|
-
});
|
|
389
|
-
}
|
|
390
|
-
}
|
|
391
|
-
const threadID = sendUpdateWrapper[4]
|
|
392
|
-
? sendUpdateWrapper[4].replace(/\|.*$/, '')
|
|
393
|
-
: undefined;
|
|
394
|
-
triggerEvent({
|
|
395
|
-
draftID: draftID,
|
|
396
|
-
type: isEmailSentResponse ? 'emailSent' : 'emailDraftReceived',
|
|
397
|
-
rfcID: sendUpdate[14],
|
|
398
|
-
messageID: sendUpdate[1],
|
|
399
|
-
oldMessageID: sendUpdate[48]
|
|
400
|
-
? new BigNumber(sendUpdate[48]).toString(16)
|
|
401
|
-
: sendUpdate[56],
|
|
402
|
-
threadID,
|
|
403
|
-
// It seems Gmail is A/B testing including gmailThreadID in response[20] and not including
|
|
404
|
-
// the encoded version of it in response[18], so pull it from [20] if [18] is not set.
|
|
405
|
-
oldThreadID: sendUpdateWrapper[18] != null
|
|
406
|
-
? new BigNumber(sendUpdateWrapper[18]).toString(16)
|
|
407
|
-
: sendUpdateWrapper[20],
|
|
408
|
-
});
|
|
409
|
-
}
|
|
410
|
-
currentSendConnectionIDs.delete(connection);
|
|
411
|
-
currentDraftSaveConnectionIDs.delete(connection);
|
|
412
|
-
currentFirstDraftSaveConnectionIDs.delete(connection);
|
|
413
|
-
}
|
|
414
|
-
},
|
|
415
|
-
});
|
|
416
|
-
}
|
|
417
|
-
}
|
|
418
|
-
// intercept and process thread responses
|
|
419
|
-
{
|
|
420
|
-
js_frame_wrappers.push({
|
|
421
|
-
isRelevantTo(connection) {
|
|
422
|
-
return !!connection.params.search && connection.params.view === 'tl';
|
|
423
|
-
},
|
|
424
|
-
async responseTextChanger(connection, responseText) {
|
|
425
|
-
// Presence of a responseTextChanger blocks Gmail from getting the partial
|
|
426
|
-
// values as this loads. We want our originalResponseTextLogger to run
|
|
427
|
-
// before Gmail has seen any of the response.
|
|
428
|
-
return responseText;
|
|
429
|
-
},
|
|
430
|
-
originalResponseTextLogger(connection) {
|
|
431
|
-
if (connection.status === 200) {
|
|
432
|
-
const responseText = connection.originalResponseText;
|
|
433
|
-
threadIdentifier.processThreadListResponse(responseText);
|
|
434
|
-
}
|
|
435
|
-
},
|
|
436
|
-
});
|
|
437
|
-
}
|
|
438
|
-
// intercept and process conversation view responses to get message metadata
|
|
439
|
-
{
|
|
440
|
-
// do this for gmail v1
|
|
441
|
-
{
|
|
442
|
-
js_frame_wrappers.push({
|
|
443
|
-
isRelevantTo(connection) {
|
|
444
|
-
return connection.params.view === 'cv';
|
|
445
|
-
},
|
|
446
|
-
originalResponseTextLogger(connection) {
|
|
447
|
-
if (connection.status === 200) {
|
|
448
|
-
const groupedMessages = GmailResponseProcessor.extractMessages(connection.originalResponseText);
|
|
449
|
-
messageMetadataHolder.add(groupedMessages);
|
|
450
|
-
}
|
|
451
|
-
},
|
|
452
|
-
});
|
|
453
|
-
}
|
|
454
|
-
// sync API based
|
|
455
|
-
{
|
|
456
|
-
// search response
|
|
457
|
-
main_wrappers.push({
|
|
458
|
-
isRelevantTo: function (connection) {
|
|
459
|
-
return /sync(?:\/u\/\d+)?\/i\/bv/.test(connection.url);
|
|
460
|
-
},
|
|
461
|
-
originalResponseTextLogger(connection) {
|
|
462
|
-
if (connection.status === 200) {
|
|
463
|
-
const threads = GmailSyncResponseProcessor.extractThreadsFromSearchResponse(connection.originalResponseText);
|
|
464
|
-
messageMetadataHolder.add(threads.map((syncThread) => ({
|
|
465
|
-
threadID: syncThread.syncThreadID,
|
|
466
|
-
messages: syncThread.extraMetaData.syncMessageData.map((syncMessage) => ({
|
|
467
|
-
date: syncMessage.date,
|
|
468
|
-
recipients: syncMessage.recipients,
|
|
469
|
-
})),
|
|
470
|
-
})));
|
|
471
|
-
}
|
|
472
|
-
},
|
|
473
|
-
});
|
|
474
|
-
// thread response
|
|
475
|
-
main_wrappers.push({
|
|
476
|
-
isRelevantTo: function (connection) {
|
|
477
|
-
return /sync(?:\/u\/\d+)?\/i\/fd/.test(connection.url);
|
|
478
|
-
},
|
|
479
|
-
originalResponseTextLogger(connection) {
|
|
480
|
-
if (connection.status === 200) {
|
|
481
|
-
const threads = GmailSyncResponseProcessor.extractThreadsFromThreadResponse(connection.originalResponseText);
|
|
482
|
-
messageMetadataHolder.add(threads.map((syncThread) => ({
|
|
483
|
-
threadID: syncThread.syncThreadID,
|
|
484
|
-
messages: syncThread.extraMetaData.syncMessageData.map((syncMessage) => ({
|
|
485
|
-
date: syncMessage.date,
|
|
486
|
-
recipients: syncMessage.recipients,
|
|
487
|
-
})),
|
|
488
|
-
})));
|
|
489
|
-
}
|
|
490
|
-
},
|
|
491
|
-
});
|
|
492
|
-
}
|
|
493
|
-
}
|
|
494
|
-
// Search suggestions modifier
|
|
495
|
-
// The content scripts tell us when they're interested in adding
|
|
496
|
-
// modifications to future suggestion results. When we see a search
|
|
497
|
-
// suggestions request come through, we signal the query string to the content
|
|
498
|
-
// scripts, wait for the same number of responses as the number of registered
|
|
499
|
-
// suggestion modifiers, and then meld them into the query response.
|
|
500
|
-
{
|
|
501
|
-
const providers = Object.create(null);
|
|
502
|
-
let currentQuery;
|
|
503
|
-
let suggestionModifications;
|
|
504
|
-
let currentQueryDefer;
|
|
505
|
-
document.addEventListener('inboxSDKregisterSuggestionsModifier', function ({ detail }) {
|
|
506
|
-
providers[detail.providerID] = {
|
|
507
|
-
position: Object.keys(providers).length,
|
|
508
|
-
};
|
|
509
|
-
});
|
|
510
|
-
document.addEventListener('inboxSDKprovideSuggestions', function ({ detail }) {
|
|
511
|
-
if (detail.query === currentQuery) {
|
|
512
|
-
const provider = providers[detail.providerID];
|
|
513
|
-
if (!provider) {
|
|
514
|
-
throw new Error('provider does not exist for providerID');
|
|
515
|
-
}
|
|
516
|
-
if (suggestionModifications == null) {
|
|
517
|
-
throw new Error('tried to modified a null suggestionModifications');
|
|
518
|
-
}
|
|
519
|
-
suggestionModifications[provider.position] = detail.suggestions;
|
|
520
|
-
if (suggestionModifications.filter(Boolean).length ===
|
|
521
|
-
Object.keys(providers).length) {
|
|
522
|
-
if (currentQueryDefer == null) {
|
|
523
|
-
throw new Error('tried to resolve a null currentQueryDefer');
|
|
524
|
-
}
|
|
525
|
-
currentQueryDefer.resolve(flatten(suggestionModifications));
|
|
526
|
-
currentQueryDefer = currentQuery = suggestionModifications = null;
|
|
527
|
-
}
|
|
528
|
-
}
|
|
529
|
-
});
|
|
530
|
-
main_wrappers.push({
|
|
531
|
-
isRelevantTo(connection) {
|
|
532
|
-
return (Object.keys(providers).length > 0 &&
|
|
533
|
-
!!connection.url.match(/^\/cloudsearch\/request\?/) &&
|
|
534
|
-
connection.params.client == 'gmail' &&
|
|
535
|
-
connection.params.gs_ri == 'gmail');
|
|
536
|
-
},
|
|
537
|
-
originalSendBodyLogger(connection, body) {
|
|
538
|
-
const parsedBody = querystring.parse(body);
|
|
539
|
-
if (!parsedBody.request) {
|
|
540
|
-
return;
|
|
541
|
-
}
|
|
542
|
-
const query = JSON.parse(parsedBody.request)[2];
|
|
543
|
-
if (!query) {
|
|
544
|
-
return;
|
|
545
|
-
}
|
|
546
|
-
currentQuery = query;
|
|
547
|
-
if (currentQueryDefer)
|
|
548
|
-
currentQueryDefer.resolve();
|
|
549
|
-
currentQueryDefer = connection._defer = defer();
|
|
550
|
-
suggestionModifications = [];
|
|
551
|
-
triggerEvent({
|
|
552
|
-
type: 'suggestionsRequest',
|
|
553
|
-
query: currentQuery,
|
|
554
|
-
});
|
|
555
|
-
},
|
|
556
|
-
async responseTextChanger(connection, responseText) {
|
|
557
|
-
if (connection._defer && connection.status === 200) {
|
|
558
|
-
const modifications = await connection._defer.promise;
|
|
559
|
-
if (modifications) {
|
|
560
|
-
return modifySuggestions(responseText, modifications);
|
|
561
|
-
}
|
|
562
|
-
}
|
|
563
|
-
return responseText;
|
|
564
|
-
},
|
|
565
|
-
});
|
|
566
|
-
}
|
|
567
|
-
{
|
|
568
|
-
// TODO: simplify this code
|
|
569
|
-
// the triggerEvent call should happen in the requestChanger callback
|
|
570
|
-
// and a lot of these state variables can be stored in the closure
|
|
571
|
-
// Search query replacer.
|
|
572
|
-
// The content script tells us search terms to watch for. Whenever we see a
|
|
573
|
-
// search query containing the term, we delay it being sent out, trigger an
|
|
574
|
-
// event containing the full query, and wait for a response event from the
|
|
575
|
-
// content script that contains a new query to substitute in.
|
|
576
|
-
const customSearchTerms = [];
|
|
577
|
-
let queryReplacement;
|
|
578
|
-
document.addEventListener('inboxSDKcreateCustomSearchTerm', function (event) {
|
|
579
|
-
customSearchTerms.push(event.detail.term);
|
|
580
|
-
});
|
|
581
|
-
document.addEventListener('inboxSDKsearchReplacementReady', function (event) {
|
|
582
|
-
if (queryReplacement.query === event.detail.query) {
|
|
583
|
-
queryReplacement.newQuery.resolve(event.detail.newQuery);
|
|
584
|
-
}
|
|
585
|
-
});
|
|
586
|
-
// classic Gmail API intercept
|
|
587
|
-
js_frame_wrappers.push({
|
|
588
|
-
isRelevantTo: function (connection) {
|
|
589
|
-
let customSearchTerm;
|
|
590
|
-
const params = connection.params;
|
|
591
|
-
if (connection.method === 'POST' &&
|
|
592
|
-
params.search &&
|
|
593
|
-
params.view === 'tl' &&
|
|
594
|
-
connection.url.match(/^\?/) &&
|
|
595
|
-
params.q &&
|
|
596
|
-
(customSearchTerm = intersection(customSearchTerms, quotedSplit(params.q))[0])) {
|
|
597
|
-
if (queryReplacement &&
|
|
598
|
-
queryReplacement.query === params.q &&
|
|
599
|
-
queryReplacement.start != params.start) {
|
|
600
|
-
// If this is the same query that was made last, but just for a
|
|
601
|
-
// different page, then re-use the replacement query we got last time.
|
|
602
|
-
// Don't wait on the extension to come up with it again (and risk it
|
|
603
|
-
// giving an inconsistent answer between pages).
|
|
604
|
-
connection._queryReplacement = queryReplacement;
|
|
605
|
-
// Mark the old queryReplacement with this page now so we can tell on
|
|
606
|
-
// a later request whether the page was changed or the list refresh
|
|
607
|
-
// button was hit.
|
|
608
|
-
queryReplacement.start = params.start;
|
|
609
|
-
}
|
|
610
|
-
else {
|
|
611
|
-
if (queryReplacement) {
|
|
612
|
-
// Resolve the old one with something because no one else is going
|
|
613
|
-
// to after it's replaced in a moment.
|
|
614
|
-
queryReplacement.newQuery.resolve(queryReplacement.query);
|
|
615
|
-
}
|
|
616
|
-
queryReplacement = connection._queryReplacement = {
|
|
617
|
-
term: customSearchTerm,
|
|
618
|
-
query: params.q,
|
|
619
|
-
start: params.start,
|
|
620
|
-
newQuery: defer(),
|
|
621
|
-
};
|
|
622
|
-
triggerEvent({
|
|
623
|
-
type: 'searchQueryForReplacement',
|
|
624
|
-
term: customSearchTerm,
|
|
625
|
-
query: params.q,
|
|
626
|
-
});
|
|
627
|
-
}
|
|
628
|
-
return true;
|
|
629
|
-
}
|
|
630
|
-
return false;
|
|
631
|
-
},
|
|
632
|
-
requestChanger: function (connection, request) {
|
|
633
|
-
return connection._queryReplacement.newQuery.promise.then(function (newQuery) {
|
|
634
|
-
const newParams = clone(connection.params);
|
|
635
|
-
newParams.q = newQuery;
|
|
636
|
-
return {
|
|
637
|
-
method: request.method,
|
|
638
|
-
url: '?' + stringify(newParams),
|
|
639
|
-
body: request.body,
|
|
640
|
-
};
|
|
641
|
-
});
|
|
642
|
-
},
|
|
643
|
-
});
|
|
644
|
-
// newer, sync API based request intercept
|
|
645
|
-
main_wrappers.push({
|
|
646
|
-
isRelevantTo: function (connection) {
|
|
647
|
-
return (connection.method === 'POST' &&
|
|
648
|
-
/sync(?:\/u\/\d+)?\/i\/bv/.test(connection.url));
|
|
649
|
-
},
|
|
650
|
-
requestChanger: function (connection, request) {
|
|
651
|
-
let customSearchTerm;
|
|
652
|
-
const body = JSON.parse(request.body);
|
|
653
|
-
let newFormat = false;
|
|
654
|
-
let payload, searchString, pageOffset;
|
|
655
|
-
if (Array.isArray(body)) {
|
|
656
|
-
newFormat = true;
|
|
657
|
-
payload = body[0];
|
|
658
|
-
searchString = payload[3];
|
|
659
|
-
pageOffset = payload[9];
|
|
660
|
-
}
|
|
661
|
-
else {
|
|
662
|
-
payload = body[1];
|
|
663
|
-
searchString = payload[4];
|
|
664
|
-
pageOffset = payload[10];
|
|
665
|
-
}
|
|
666
|
-
const isSyncAPISearchWithCustomTerm = payload[newFormat ? 0 : 1] === 79 &&
|
|
667
|
-
typeof searchString === 'string' &&
|
|
668
|
-
(customSearchTerm = intersection(customSearchTerms, quotedSplit(searchString))[0]);
|
|
669
|
-
if (!isSyncAPISearchWithCustomTerm)
|
|
670
|
-
return Promise.resolve(request);
|
|
671
|
-
if (queryReplacement &&
|
|
672
|
-
queryReplacement.query === searchString &&
|
|
673
|
-
queryReplacement.start != pageOffset) {
|
|
674
|
-
// If this is the same query that was made last, but just for a
|
|
675
|
-
// different page, then re-use the replacement query we got last time.
|
|
676
|
-
// Don't wait on the extension to come up with it again (and risk it
|
|
677
|
-
// giving an inconsistent answer between pages).
|
|
678
|
-
connection._queryReplacement = queryReplacement;
|
|
679
|
-
// Mark the old queryReplacement with this page now so we can tell on
|
|
680
|
-
// a later request whether the page was changed or the list refresh
|
|
681
|
-
// button was hit.
|
|
682
|
-
queryReplacement.start = pageOffset;
|
|
683
|
-
}
|
|
684
|
-
else {
|
|
685
|
-
if (queryReplacement) {
|
|
686
|
-
// Resolve the old one with something because no one else is going
|
|
687
|
-
// to after it's replaced in a moment.
|
|
688
|
-
queryReplacement.newQuery.resolve(queryReplacement.query);
|
|
689
|
-
}
|
|
690
|
-
queryReplacement = connection._queryReplacement = {
|
|
691
|
-
term: customSearchTerm,
|
|
692
|
-
query: searchString,
|
|
693
|
-
start: pageOffset,
|
|
694
|
-
newQuery: defer(),
|
|
695
|
-
};
|
|
696
|
-
triggerEvent({
|
|
697
|
-
type: 'searchQueryForReplacement',
|
|
698
|
-
term: customSearchTerm,
|
|
699
|
-
query: searchString,
|
|
700
|
-
});
|
|
701
|
-
}
|
|
702
|
-
return connection._queryReplacement.newQuery.promise.then(function (newQuery) {
|
|
703
|
-
if (newFormat) {
|
|
704
|
-
body[0][3] = newQuery;
|
|
705
|
-
}
|
|
706
|
-
else {
|
|
707
|
-
body[1][4] = newQuery;
|
|
708
|
-
}
|
|
709
|
-
return {
|
|
710
|
-
method: request.method,
|
|
711
|
-
url: request.url,
|
|
712
|
-
body: JSON.stringify(body),
|
|
713
|
-
};
|
|
714
|
-
});
|
|
715
|
-
},
|
|
716
|
-
});
|
|
717
|
-
}
|
|
718
|
-
{
|
|
719
|
-
// Search results replacer.
|
|
720
|
-
// The content script tells us a search query to watch for. Whenever we see
|
|
721
|
-
// the search query, trigger an event containing the query, trigger an
|
|
722
|
-
// event containing the response, and then wait for a response event from
|
|
723
|
-
// the content script that contains new results to substitute in.
|
|
724
|
-
const customSearchQueries = [];
|
|
725
|
-
let customListJob;
|
|
726
|
-
document.addEventListener('inboxSDKcustomListRegisterQuery', (event) => {
|
|
727
|
-
customSearchQueries.push(event.detail.query);
|
|
728
|
-
});
|
|
729
|
-
document.addEventListener('inboxSDKcustomListNewQuery', (event) => {
|
|
730
|
-
if (customListJob.query === event.detail.query &&
|
|
731
|
-
customListJob.start === event.detail.start) {
|
|
732
|
-
const { newQuery, newStart } = event.detail;
|
|
733
|
-
customListJob.newRequestParams.resolve({
|
|
734
|
-
query: newQuery,
|
|
735
|
-
start: newStart,
|
|
736
|
-
});
|
|
737
|
-
}
|
|
738
|
-
});
|
|
739
|
-
document.addEventListener('inboxSDKcustomListResults', (event) => {
|
|
740
|
-
if (customListJob.query === event.detail.query) {
|
|
741
|
-
customListJob.newResults.resolve(event.detail.newResults);
|
|
742
|
-
}
|
|
743
|
-
});
|
|
744
|
-
js_frame_wrappers.push({
|
|
745
|
-
isRelevantTo: function (connection) {
|
|
746
|
-
const params = connection.params;
|
|
747
|
-
if (connection.method === 'POST' &&
|
|
748
|
-
params.search &&
|
|
749
|
-
params.view === 'tl' &&
|
|
750
|
-
connection.url.match(/^\?/) &&
|
|
751
|
-
params.q &&
|
|
752
|
-
!params.act &&
|
|
753
|
-
find(customSearchQueries, (x) => x === params.q)) {
|
|
754
|
-
if (customListJob) {
|
|
755
|
-
// Resolve the old one with something because no one else is going
|
|
756
|
-
// to after it's replaced in a moment.
|
|
757
|
-
customListJob.newRequestParams.resolve({
|
|
758
|
-
query: customListJob.query,
|
|
759
|
-
start: customListJob.start,
|
|
760
|
-
});
|
|
761
|
-
customListJob.newResults.resolve(null);
|
|
762
|
-
}
|
|
763
|
-
customListJob = connection._customListJob = {
|
|
764
|
-
query: params.q,
|
|
765
|
-
start: +params.start,
|
|
766
|
-
newRequestParams: defer(),
|
|
767
|
-
newResults: defer(),
|
|
768
|
-
};
|
|
769
|
-
triggerEvent({
|
|
770
|
-
type: 'searchForReplacement',
|
|
771
|
-
query: customListJob.query,
|
|
772
|
-
start: customListJob.start,
|
|
773
|
-
});
|
|
774
|
-
return true;
|
|
775
|
-
}
|
|
776
|
-
return false;
|
|
777
|
-
},
|
|
778
|
-
requestChanger: function (connection, request) {
|
|
779
|
-
return connection._customListJob.newRequestParams.promise.then(({ query, start }) => {
|
|
780
|
-
const newParams = clone(connection.params);
|
|
781
|
-
newParams.q = query;
|
|
782
|
-
newParams.start = start;
|
|
783
|
-
return {
|
|
784
|
-
method: request.method,
|
|
785
|
-
url: '?' + stringify(newParams),
|
|
786
|
-
body: request.body,
|
|
787
|
-
};
|
|
788
|
-
});
|
|
789
|
-
},
|
|
790
|
-
responseTextChanger: function (connection, response) {
|
|
791
|
-
triggerEvent({
|
|
792
|
-
type: 'searchResultsResponse',
|
|
793
|
-
query: connection._customListJob.query,
|
|
794
|
-
start: connection._customListJob.start,
|
|
795
|
-
response,
|
|
796
|
-
});
|
|
797
|
-
return connection._customListJob.newResults.promise.then((newResults) => (newResults === null ? response : newResults));
|
|
798
|
-
},
|
|
799
|
-
});
|
|
800
|
-
// Sync API-based custom thread list interception
|
|
801
|
-
main_wrappers.push({
|
|
802
|
-
isRelevantTo: function (connection) {
|
|
803
|
-
if (/sync(?:\/u\/\d+)?\/i\/bv/.test(connection.url)) {
|
|
804
|
-
if (customListJob) {
|
|
805
|
-
// Resolve the old one with something because no one else is going
|
|
806
|
-
// to after it's replaced in a moment.
|
|
807
|
-
customListJob.newRequestParams.resolve({
|
|
808
|
-
query: customListJob.query,
|
|
809
|
-
start: customListJob.start,
|
|
810
|
-
});
|
|
811
|
-
customListJob.newResults.resolve(null);
|
|
812
|
-
}
|
|
813
|
-
return true;
|
|
814
|
-
}
|
|
815
|
-
return false;
|
|
816
|
-
},
|
|
817
|
-
requestChanger: async function (connection, request) {
|
|
818
|
-
if (request.body) {
|
|
819
|
-
const parsedBody = JSON.parse(request.body);
|
|
820
|
-
const newFormat = Array.isArray(parsedBody);
|
|
821
|
-
// we are a search!
|
|
822
|
-
const searchQuery = (newFormat
|
|
823
|
-
? parsedBody && parsedBody[0] && parsedBody[0][3]
|
|
824
|
-
: parsedBody && parsedBody[1] && parsedBody[1][4]) || '';
|
|
825
|
-
if (find(customSearchQueries, (x) => x === searchQuery)) {
|
|
826
|
-
customListJob = connection._customListJob = {
|
|
827
|
-
query: searchQuery,
|
|
828
|
-
start: newFormat ? parsedBody[0][9] : parsedBody[1][10],
|
|
829
|
-
newRequestParams: defer(),
|
|
830
|
-
newResults: defer(),
|
|
831
|
-
};
|
|
832
|
-
triggerEvent({
|
|
833
|
-
type: 'searchForReplacement',
|
|
834
|
-
query: customListJob.query,
|
|
835
|
-
start: customListJob.start,
|
|
836
|
-
});
|
|
837
|
-
return connection._customListJob.newRequestParams.promise.then(({ query, start }) => {
|
|
838
|
-
if (newFormat) {
|
|
839
|
-
parsedBody[0][3] = query;
|
|
840
|
-
parsedBody[0][9] = start;
|
|
841
|
-
}
|
|
842
|
-
else {
|
|
843
|
-
parsedBody[1][4] = query;
|
|
844
|
-
parsedBody[1][10] = start;
|
|
845
|
-
}
|
|
846
|
-
return {
|
|
847
|
-
method: request.method,
|
|
848
|
-
url: request.url,
|
|
849
|
-
body: JSON.stringify(parsedBody),
|
|
850
|
-
};
|
|
851
|
-
});
|
|
852
|
-
}
|
|
853
|
-
}
|
|
854
|
-
return request;
|
|
855
|
-
},
|
|
856
|
-
responseTextChanger: async function (connection, response) {
|
|
857
|
-
if (connection._customListJob) {
|
|
858
|
-
triggerEvent({
|
|
859
|
-
type: 'searchResultsResponse',
|
|
860
|
-
query: connection._customListJob.query,
|
|
861
|
-
start: connection._customListJob.start,
|
|
862
|
-
response,
|
|
863
|
-
});
|
|
864
|
-
return connection._customListJob.newResults.promise.then((newResults) => (newResults === null ? response : newResults));
|
|
865
|
-
}
|
|
866
|
-
else {
|
|
867
|
-
return response;
|
|
868
|
-
}
|
|
869
|
-
},
|
|
870
|
-
});
|
|
871
|
-
}
|
|
872
|
-
// sync token savers
|
|
873
|
-
{
|
|
874
|
-
const saveBTAIHeader = (header) => {
|
|
875
|
-
document.head.setAttribute('data-inboxsdk-btai-header', header);
|
|
876
|
-
triggerEvent({
|
|
877
|
-
type: 'btaiHeaderReceived',
|
|
878
|
-
});
|
|
879
|
-
};
|
|
880
|
-
main_wrappers.push({
|
|
881
|
-
isRelevantTo(connection) {
|
|
882
|
-
return (/sync(?:\/u\/\d+)?\//.test(connection.url) &&
|
|
883
|
-
!document.head.hasAttribute('data-inboxsdk-btai-header'));
|
|
884
|
-
},
|
|
885
|
-
originalSendBodyLogger(connection) {
|
|
886
|
-
if (connection.headers['X-Gmail-BTAI']) {
|
|
887
|
-
saveBTAIHeader(connection.headers['X-Gmail-BTAI']);
|
|
888
|
-
}
|
|
889
|
-
},
|
|
890
|
-
});
|
|
891
|
-
const saveXsrfTokenHeader = (header) => {
|
|
892
|
-
document.head.setAttribute('data-inboxsdk-xsrf-token', header);
|
|
893
|
-
triggerEvent({
|
|
894
|
-
type: 'xsrfTokenHeaderReceived',
|
|
895
|
-
});
|
|
896
|
-
};
|
|
897
|
-
main_wrappers.push({
|
|
898
|
-
isRelevantTo(connection) {
|
|
899
|
-
return (/sync(?:\/u\/\d+)?\//.test(connection.url) &&
|
|
900
|
-
!document.head.hasAttribute('data-inboxsdk-xsrf-token'));
|
|
901
|
-
},
|
|
902
|
-
originalSendBodyLogger(connection) {
|
|
903
|
-
if (connection.headers['X-Framework-Xsrf-Token']) {
|
|
904
|
-
saveXsrfTokenHeader(connection.headers['X-Framework-Xsrf-Token']);
|
|
905
|
-
}
|
|
906
|
-
},
|
|
907
|
-
});
|
|
908
|
-
}
|
|
909
|
-
}
|
|
910
|
-
function triggerEvent(detail) {
|
|
911
|
-
document.dispatchEvent(new CustomEvent('inboxSDKajaxIntercept', {
|
|
912
|
-
bubbles: true,
|
|
913
|
-
cancelable: false,
|
|
914
|
-
detail,
|
|
915
|
-
}));
|
|
916
|
-
}
|
|
917
|
-
function stringifyComposeParams(inComposeParams) {
|
|
918
|
-
const composeParams = clone(inComposeParams);
|
|
919
|
-
const string = `=${stringifyComposeRecipientParam(composeParams.to, 'to')}&=${stringifyComposeRecipientParam(composeParams.cc, 'cc')}&=${stringifyComposeRecipientParam(composeParams.bcc, 'bcc')}`;
|
|
920
|
-
delete composeParams.to;
|
|
921
|
-
delete composeParams.bcc;
|
|
922
|
-
delete composeParams.cc;
|
|
923
|
-
return string + '&' + querystring.stringify(composeParams);
|
|
924
|
-
}
|
|
925
|
-
function stringifyComposeRecipientParam(value, paramType) {
|
|
926
|
-
let string = '';
|
|
927
|
-
if (Array.isArray(value)) {
|
|
928
|
-
for (let ii = 0; ii < value.length; ii++) {
|
|
929
|
-
string += `&${paramType}=${encodeURIComponent(value[ii])}`;
|
|
930
|
-
}
|
|
931
|
-
}
|
|
932
|
-
else {
|
|
933
|
-
string += `&${paramType}=${encodeURIComponent(value)}`;
|
|
934
|
-
}
|
|
935
|
-
return string;
|
|
936
|
-
}
|