Disable Outlook Reading Pane Zooming

as the name states

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Disable Outlook Reading Pane Zooming
// @license      MIT
// @namespace    http://greasyfork.org/
// @version      0.2
// @description  as the name states
// @author       You
// @match        https://outlook.office.com/mail/*
// @match        https://outlook.office365.com/mail/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=office.com
// @grant        none
// @run-at       document-idle
// ==/UserScript==

(function () {
  "use strict";

  // Remember the previous paneDiv element
  let previousPaneDiv = null;

  // Define the callback function to execute when the paneDiv element is created
  const onPaneDivCreated = function (mutationsList, observer) {
    for (let mutation of mutationsList) {
      if (mutation.type === "childList" && mutation.addedNodes.length) {
        // If the addedNodes list contains the paneDiv element, execute the code block
        const currentPaneDiv = document.querySelector(
          "#ReadingPaneContainerId > div > div > div"
        );

        if (currentPaneDiv && currentPaneDiv !== previousPaneDiv) {
          // Remove the event listener from the previous paneDiv element
          if (previousPaneDiv) {
            previousPaneDiv.removeEventListener("wheel", stopPropagation, true);
          }

          // Add the event listener to the current paneDiv element
          currentPaneDiv.addEventListener("wheel", stopPropagation, true);

          // Remember the current paneDiv element as the previous one
          previousPaneDiv = currentPaneDiv;
        }
      }
    }
  };

  // Define the function to stop event propagation
  const stopPropagation = function (e) {
    e.stopPropagation();
  };

  // Create a new MutationObserver object and pass in the callback function
  const observer = new MutationObserver(onPaneDivCreated);

  // Configure the observer to watch for changes to the parent of the paneDiv element
  const config = { childList: true, subtree: true };
  const parentElement = document;

  // Start observing the parent element for changes
  observer.observe(parentElement, config);
})();