QcTorrent - Shoutbox notifications

Affiche une notification de bureau lors de la réception d'un message

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name         QcTorrent - Shoutbox notifications
// @version		 1.0
// @namespace    qctorrent.io
// @description  Affiche une notification de bureau lors de la réception d'un message
// @author       M1st3rN0b0d7
// @match        https://www.qctorrent.io/chat
// @match		 https://www.qctorrent.io/chat.php
// @match        http://www.qctorrent.io/chat
// @match		 http://www.qctorrent.io/chat.php
// @grant        none
// ==/UserScript==

document.addEventListener('DOMContentLoaded', function () {
  if (Notification.permission !== "granted")
    Notification.requestPermission();
});

var me = prompt("Veuillez entrer votre nom d'utilisateur QcTorrent.");
// var me = "M1st3rN0b0d7";

var msg2 = "";

function loop(){

	var msg_all = document.getElementsByClassName("shout-msg");
	var msg_last = msg_all.length - 1;
	var msg = msg_all[msg_last];

	var reply = msg.getElementsByTagName("b")[0];

	if(reply !== undefined){

		var replyTo = reply.innerText;

	}

	var replyTo_2 = replyTo + " - ";

	var user = msg.getElementsByTagName("strong");
	user = user[0].innerText.trim();

	var time = msg.getElementsByTagName("em");
	time = time[0].innerText;

	msg = msg.innerText.replace(user, "").replace(time, "").replace(replyTo_2, "").trim();

	if(replyTo !== undefined){

		var test = replyTo.search(me);

	}

	if(test !== -1 && test !== undefined && msg !== msg2) {

		msg2 = msg;

		notifyMe();

	}

	console.log("User : " + user + "\n" + "Reply To : " + replyTo + "\n" + "Test : " + test + "\n" + "Msg : " + msg);

 	function notifyMe() {

    	if (!Notification) {

      	alert('Notifications de bureau non supportées.');
    	return;

   		}

    	if (Notification.permission !== "granted")
     		Notification.requestPermission();

   	 	else {

      	var notification = new Notification('Shoutbox QcTorrent', {

       	 icon: 'https://i.goopics.net/6Y9R.png',
         body: "Message de " + user + "\n" + msg,

    	});

      	var audio = new Audio("http://mobilering.net/ringtones/mp3/sound-effects/facebook_pop.mp3");
      	audio.volume = 0.3;
      	audio.play();

  	  }

  	}

  	function highlightMe(){

  		var strong_me = "strong#" + me;

 		var user_me = document.querySelectorAll(strong_me);

		for (var i = 0; i < user_me.length; i++) {

    		user_me[i].setAttribute('style', 'background-color: #3498db!important; border: 3px solid red;');

		}

  	}

  	highlightMe();

}

var loopFunction = window.setInterval(loop, 100);