Disable Auto Popping Designer Pane for online office

Completely kill the Designer pane in PowerPoint Online

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Disable Auto Popping Designer Pane for online office
// @namespace    http://tampermonkey.net/
// @version      0.3
// @description  Completely kill the Designer pane in PowerPoint Online
// @match        https://*.office.com/*
// @match        https://*.powerpoint.office.com/*
// @match        https://*.officeapps.live.com/*
// @match        https://*.sharepoint.com/*
// @run-at       document-start
// @grant        none
// @license MIT
// ==/UserScript==

(function() {
    'use strict';

    // Inject CSS to hide any possible Designer pane containers
    const css = `
      /* the main “FarPane” container */
      #FarPane,
      /* fallback if the ID is different */
      #FarPaneRegion,
      /* the task-pane wrapper on the right */
      .WACTaskPaneContainerRight,
      /* the Designer pane itself */
      .DesignerPane {
        display: none !important;
      }
    `;
    const s = document.createElement('style');
    s.textContent = css;
    document.head.appendChild(s);

    // As a safety, also watch for any new panes being inserted and kill them
    const observer = new MutationObserver((records, obs) => {
      let removed = false;
      document.querySelectorAll('#FarPane, #FarPaneRegion, .WACTaskPaneContainerRight, .DesignerPane')
        .forEach(el => {
          if (el.style.display !== 'none') {
            el.style.display = 'none';
            removed = true;
          }
        });
      if (removed) {
        console.log('[TM] Designer pane hidden');
      }
    });

    // Start observing as soon as <body> exists
    const start = () => {
      const body = document.body;
      if (!body) return setTimeout(start, 50);
      observer.observe(body, { childList: true, subtree: true });
      // one last manual pass
      observer.takeRecords();
    };
    start();
})();