Notification Enhancer

Notification Enhancer script

  1. // ==UserScript==
  2. // @name Notification Enhancer
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.2
  5. // @description Notification Enhancer script
  6. // @author Realwdpcker
  7. // @match https://pixelplace.io/*
  8. // @grant none
  9. // @license MIT
  10. // ==/UserScript==
  11.  
  12. (function () {
  13. 'use strict';
  14.  
  15. const getVolume = (key, defaultValue) => {
  16. const val = localStorage.getItem(key);
  17. return val !== null ? parseFloat(val) : defaultValue;
  18. };
  19.  
  20. const setVolume = (key, value) => {
  21. localStorage.setItem(key, value.toString());
  22. };
  23.  
  24. const warningSound = new Audio('https://cdn.uppbeat.io/audio-files/a34d50ecafdf61ec63b0f3d2f41f9998/18d864b70347c0e38362eb8af60aec76/a29e3c935133c0fdd759e7a61725fbc5/STREAMING-positive-notification-digital-ding-gamemaster-audio-1-00-01.mp3');
  25. const successSound = new Audio('https://cdn.uppbeat.io/audio-files/a34d50ecafdf61ec63b0f3d2f41f9998/b9ca7d21360f106c0fe9ea3cb80000ea/7a14a9faba4c1884bb8eb46ad3f1fa9e/STREAMING-positive-notification-digital-beep-double-gamemaster-audio-1-00-02.mp3');
  26. const errorSound = new Audio('https://cdn.uppbeat.io/audio-files/06ae18f31ba6d2a5dd6b6f941ae28d0a/d3e6f01a2b686bb9d88df304bb54e46c/7bf25893b999d81e63f376f8b0d634d4/STREAMING-ui-access-denied-jam-fx-1-00-01.mp3');
  27.  
  28. warningSound.volume = getVolume('warningVolume', 0.5);
  29. successSound.volume = getVolume('successVolume', 0.5);
  30. errorSound.volume = getVolume('errorVolume', 0.5);
  31.  
  32. const menu = document.createElement('div');
  33. menu.id = 'notificationVolumeMenu';
  34. menu.style.cssText = `
  35. position: fixed;
  36. top: 100px;
  37. right: 20px;
  38. background: #222222;
  39. color: white;
  40. padding: 5px;
  41. font-family: Consolas, sans-serif;
  42. z-index: 99999;
  43. border: 2.5px solid rgb(0, 226, 255);
  44. display: none;
  45. `;
  46.  
  47. menu.innerHTML = `
  48. <label style="font-family: Consolas, sans-serif;">Warning: <input type="range" id="warningVolume" min="0" max="1" step="0.01" value="${warningSound.volume}"></label><br>
  49. <label style="font-family: Consolas, sans-serif;">Success: <input type="range" id="successVolume" min="0" max="1" step="0.01" value="${successSound.volume}"></label><br>
  50. <label style="font-family: Consolas, sans-serif;">Error: <input type="range" id="errorVolume" min="0" max="1" step="0.01" value="${errorSound.volume}"></label>
  51. `;
  52. document.body.appendChild(menu);
  53.  
  54. const style = document.createElement('style');
  55. style.textContent = `
  56. #notificationVolumeMenu input[type="range"]::-webkit-slider-thumb {
  57. -webkit-appearance: none;
  58. appearance: none;
  59. background: #ffffff;
  60. cursor: pointer;
  61. }
  62.  
  63. #notificationVolumeMenu input[type="range"]::-webkit-slider-runnable-track {
  64. background: #444;
  65. border-radius: 0px;
  66. }
  67. `;
  68. document.head.appendChild(style);
  69.  
  70. document.getElementById('warningVolume').addEventListener('input', e => {
  71. const vol = parseFloat(e.target.value);
  72. warningSound.volume = vol;
  73. setVolume('warningVolume', vol);
  74. });
  75.  
  76. document.getElementById('successVolume').addEventListener('input', e => {
  77. const vol = parseFloat(e.target.value);
  78. successSound.volume = vol;
  79. setVolume('successVolume', vol);
  80. });
  81.  
  82. document.getElementById('errorVolume').addEventListener('input', e => {
  83. const vol = parseFloat(e.target.value);
  84. errorSound.volume = vol;
  85. setVolume('errorVolume', vol);
  86. });
  87.  
  88. document.addEventListener('keydown', function (e) {
  89. if (e.altKey && e.key.toLowerCase() === 'm') {
  90. const isVisible = menu.style.display === 'block';
  91. menu.style.display = isVisible ? 'none' : 'block';
  92. }
  93. });
  94.  
  95. const observer = new MutationObserver((mutations) => {
  96. for (const mutation of mutations) {
  97. for (const node of mutation.addedNodes) {
  98. if (node.nodeType === Node.ELEMENT_NODE) {
  99. const el = node;
  100.  
  101. if (el.matches('.box.warning')) {
  102. warningSound.currentTime = 0;
  103. warningSound.play();
  104. } else if (el.matches('.box.success')) {
  105. successSound.currentTime = 0;
  106. successSound.play();
  107. } else if (el.matches('.box.error')) {
  108. errorSound.currentTime = 0;
  109. errorSound.play();
  110. }
  111. }
  112. }
  113. }
  114. });
  115.  
  116. const waitForContainer = setInterval(() => {
  117. const container = document.querySelector('#notification');
  118. if (container) {
  119. clearInterval(waitForContainer);
  120. observer.observe(container, { childList: true, subtree: true });
  121. }
  122. }, 500);
  123. })();

QingJ © 2025

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