Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name [Leek Wars] Ah !
- // @namespace https://github.com/PerthuisQuentin/Leek-Wars-Scripts/
- // @version 0.3.2
- // @description Déclenche un "Ah !" sonore lors d'un "Ah !" dans le chat (TAISEZ-VOUS !!!)
- // @author TheTintin (Onys)
- // @projectPage https://github.com/PerthuisQuentin/Leek-Wars-Scripts/
- // @AdownloadURL https://github.com/PerthuisQuentin/Leek-Wars-Scripts/raw/master/Ah/ah.user.js
- // @AupdateURL https://github.com/PerthuisQuentin/Leek-Wars-Scripts/raw/master/Ah/ah.user.js
- // @match *://*.leekwars.com/*
- // ==/UserScript==
- (function() {
- 'use strict';
- var audio_ah = new Audio('https://raw.githubusercontent.com/PerthuisQuentin/Leek-Wars-Scripts/master/Ah/ah.wav');
- var audio_tv = new Audio('https://puu.sh/v3ep2/f5331c17ba.mp3');
- var regex_ah = new RegExp(/(ah\s?!)/ig);
- var regex_tv = new RegExp(/(taisez-vous(\s)?!)/ig);
- function check(message) {
- var count = message.match(regex_ah).length;
- if(!count) return;
- (function loop() {
- audio_ah.play();
- count--;
- if(count > 0) setTimeout(loop, 500);
- })();
- count = message.match(regex_tv).length;
- if(!count) return;
- (function loop() {
- audio_tv.play();
- count--;
- if(count > 0) setTimeout(loop, 500);
- })();
- }
- LW.on('pageload', function() {
- var chatReceive = LW.chat.receive;
- var messageReceive = LW.messages.receive;
- LW.chat.receive = function(data) {
- check(data[3]);
- chatReceive(data);
- };
- LW.messages.receive = function(data) {
- check(data.message);
- messageReceive(data);
- };
- });
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement