Advertisement
Guest User

Untitled

a guest
Mar 30th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name         [Leek Wars] Ah !
  3. // @namespace    https://github.com/PerthuisQuentin/Leek-Wars-Scripts/
  4. // @version      0.3.2
  5. // @description  Déclenche un "Ah !" sonore lors d'un "Ah !" dans le chat (TAISEZ-VOUS !!!)
  6. // @author       TheTintin (Onys)
  7. // @projectPage   https://github.com/PerthuisQuentin/Leek-Wars-Scripts/
  8. // @AdownloadURL   https://github.com/PerthuisQuentin/Leek-Wars-Scripts/raw/master/Ah/ah.user.js
  9. // @AupdateURL     https://github.com/PerthuisQuentin/Leek-Wars-Scripts/raw/master/Ah/ah.user.js
  10. // @match         *://*.leekwars.com/*
  11. // ==/UserScript==
  12.  
  13. (function() {
  14.     'use strict';
  15.  
  16.     var audio_ah = new Audio('https://raw.githubusercontent.com/PerthuisQuentin/Leek-Wars-Scripts/master/Ah/ah.wav');
  17.     var audio_tv = new Audio('https://puu.sh/v3ep2/f5331c17ba.mp3');
  18.     var regex_ah = new RegExp(/(ah\s?!)/ig);
  19.     var regex_tv = new RegExp(/(taisez-vous(\s)?!)/ig);
  20.  
  21.     function check(message) {
  22.         var count = message.match(regex_ah).length;
  23.         if(!count) return;
  24.         (function loop() {
  25.             audio_ah.play();
  26.             count--;
  27.             if(count > 0) setTimeout(loop, 500);
  28.         })();
  29.        
  30.         count = message.match(regex_tv).length;
  31.         if(!count) return;
  32.         (function loop() {
  33.             audio_tv.play();
  34.             count--;
  35.             if(count > 0) setTimeout(loop, 500);
  36.         })();
  37.     }
  38.  
  39.     LW.on('pageload', function() {
  40.         var chatReceive = LW.chat.receive;
  41.         var messageReceive = LW.messages.receive;
  42.  
  43.         LW.chat.receive = function(data) {
  44.             check(data[3]);
  45.             chatReceive(data);
  46.         };
  47.  
  48.         LW.messages.receive = function(data) {
  49.             check(data.message);
  50.             messageReceive(data);
  51.         };
  52.     });
  53. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement