Better Zendesk for BandLab

Zendesk enhancements for BandLab support team

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Better Zendesk for BandLab
// @namespace    https://www.bandlab.com/
// @version      0.2
// @description  Zendesk enhancements for BandLab support team
// @author       Gilles
// @match        https://*.zendesk.com/agent/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=zendesk.com
// @grant        none
// @license MIT
// ==/UserScript==

(function () {
  "use strict";

  // Use ALT+Number to switch between panel on Zendesk
  document.addEventListener("keydown", function (event) {
    if (event.altKey) {
      switch (event.code) {
        case "Digit1":
          document
            .querySelector('[data-cy-test-element="customer-context"]')
            .click();
          event.preventDefault();
          break;
        case "Digit2":
          document
            .querySelector('[data-cy-test-element="guide-suggestions"]')
            .click();
          event.preventDefault();
          break;
        case "Digit3":
          document
            .querySelector('[data-cy-test-element="smart-assist"]')
            .click();
          event.preventDefault();
          break;
        case "Digit4":
          document.querySelector('[data-cy-test-element="apps"]').click();
          event.preventDefault();
          break;
        default:
          break;
      }
    }
  });

  // Uncheck "Requester can see this comment"
  const observer = new MutationObserver(function (mutationsList, observer) {
    for (const mutation of mutationsList) {
      if (mutation.type === "childList" && mutation.addedNodes.length > 0) {
        const newCheckboxes = document.querySelectorAll(
          'input[type="checkbox"][name$="_is_public"]',
        );
        newCheckboxes.forEach(function (checkbox) {
          checkbox.checked = false;
        });
      }
    }
  });
  observer.observe(document.body, { childList: true, subtree: true });
})();