Zendesk Notification Sound & Highlight Updated

Play sound and change button style when a new notification arrives in Zendesk.

  1. // ==UserScript==
  2. // @name Zendesk Notification Sound & Highlight Updated
  3. // @namespace https://yourdomain.com
  4. // @version 3.0
  5. // @description Play sound and change button style when a new notification arrives in Zendesk.
  6. // @author KoKa_UA
  7. // @match *://*.zendesk.com/*
  8. // @grant GM_addStyle
  9. // @license MIT
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15.  
  16. const notificationSound = new Audio("https://zvukitop.com/wp-content/uploads/2021/03/zvuki-opovesheniya.mp3");
  17.  
  18.  
  19.  
  20.  
  21. function checkForNewMessages(mutationsList) {
  22.  
  23. const unreadCountElement = document.querySelector('[data-test-id="awm-unread-count"]');
  24. const notificationButton = document.querySelector('button[aria-label="Notifications"]');
  25.  
  26. if (unreadCountElement && notificationButton) {
  27. if (unreadCountElement.innerText.trim() !== "0" && unreadCountElement.innerText.trim() !== "") {
  28. notificationSound.play();
  29. notificationButton.classList.add("has-new-messages");
  30. } else {
  31. notificationButton.classList.remove("has-new-messages");
  32. }
  33. }
  34. }
  35.  
  36.  
  37. function startObserver() {
  38. const targetNode = document.body;
  39. const config = { childList: true, subtree: true };
  40.  
  41. const observer = new MutationObserver(checkForNewMessages);
  42. observer.observe(targetNode, config);
  43.  
  44. }
  45.  
  46. window.addEventListener('load', function() {
  47. setTimeout(startObserver, 5000);
  48. });
  49.  
  50. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址