Custom Message Tones

Adds options to load in custom tones when a message is received.

  1. // ==UserScript==
  2. // @name Custom Message Tones
  3. // @namespace pxgamer
  4. // @version 0.5
  5. // @description Adds options to load in custom tones when a message is received.
  6. // @author pxgamer
  7. // @include *kat.cr/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (function() {
  12.  
  13. var AUDIO_FILE = ""; // URL of audio file (MP3, WAV, OGG)
  14. var AUDIO_LENGTH = 5000; // Length in Ticks
  15.  
  16. // Do Not Edit Below Here
  17. var acMethod = jQuery.fn.addClass;
  18. var audio1;
  19.  
  20. jQuery.fn.addClass = function() {
  21. var result = acMethod.apply(this, arguments);
  22.  
  23. jQuery(this).trigger('cssClassChanged');
  24.  
  25. return result;
  26. };
  27.  
  28. $('body').append('<span id="chatMsgHandler"></span>');
  29. $('#chatMsgHandler').css('display', 'none');
  30. $(document).on('cssClassChanged', function() {
  31. var msgBarElem = $('.chat-bar-new');
  32. if (msgBarElem.length > 0) {
  33. audio1.play();
  34. setTimeout(function() { audio1.pause(); audio1.currentTime = 0; }, AUDIO_LENGTH);
  35. }
  36. });
  37.  
  38. var audioTypes = {
  39. "mp3": "audio/mpeg",
  40. "ogg": "audio/ogg",
  41. "wav": "audio/wav"
  42. };
  43.  
  44. function pxS(sound) {
  45. var audio_element = document.createElement('audio');
  46. if (audio_element.canPlayType) {
  47. for (var i = 0; i < arguments.length; i++) {
  48. var source_element = document.createElement('source');
  49. source_element.setAttribute('src', arguments[i]);
  50. if (arguments[i].match(/\.(\w+)$/i)) {
  51. source_element.setAttribute('type', audioTypes[RegExp.$1]);
  52. }
  53. audio_element.appendChild(source_element);
  54. }
  55. audio_element.load();
  56. audio_element.pFunc = function() {
  57. audio_element.pause();
  58. audio_element.currentTime = 0;
  59. audio_element.play();
  60. };
  61. return audio_element;
  62. }
  63. }
  64.  
  65. audio1 = pxS(AUDIO_FILE);
  66.  
  67. })();

QingJ © 2025

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