Fic's Mixify Auto Welcome Script

This script can be used on Mixify.com while streaming your DJ set. The main reason why I created this script is that I couldn't see every single person who enters the stream so I thought it could be nice if script can annonce in chat who entered the stream with a warm welcome message.

当前为 2015-08-20 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Fic's Mixify Auto Welcome Script
  3. // @namespace Booth
  4. // @include http://www.mixify.com/*/live/*
  5. // @version 1
  6. // @grant none
  7. // @description This script can be used on Mixify.com while streaming your DJ set. The main reason why I created this script is that I couldn't see every single person who enters the stream so I thought it could be nice if script can annonce in chat who entered the stream with a warm welcome message.
  8. // ==/UserScript==
  9.  
  10. var session = []; /* List of all users that entered the stream */
  11. var DJ = $("#marqueeTitle")[0].innerHTML.replace('</h1>', '').replace('<h1>', '').trim(); /*Currnt DJ name*/
  12. var me = $("ul#userDropDown li:eq(2) a").text().trim(); /* Your name on Mixify */
  13.  
  14. /* If you are on your own stream script is running */
  15. if (me === DJ) {
  16. session.push(DJ);
  17. setInterval( /* Calling AJAX that is called my hovering mouse over attendees icon */
  18. function () {
  19. $("#specatorsDockItem").mousemove();
  20. setTimeout(
  21. function () {
  22. $("#specatorsDockItem").mouseout();
  23. }, 500);
  24.  
  25.  
  26. var users = document.getElementsByClassName("username");
  27. for (i = 0; i < users.length; i++) {
  28. if (users[i].getAttribute("target") !== null && users[i].innerHTML != "Guest" && jQuery.inArray(users[i].innerHTML.trim(), session) === -1) { /* Ignore duplicates and guests */
  29. console.log("New guest is: " + users[i].innerHTML);
  30. $("#chat_input").val("Welcome " + users[i].innerHTML.trim() + "!"); /* Post welcome msg in chat */
  31. $('#chat_input').focus().trigger(jQuery.Event('keydown', { keyCode: 13 }));
  32. session.push(users[i].innerHTML.trim()); /* Mark user as the one that already visited the stream */
  33. }
  34. }
  35. }, 5000); /* Check for new guests every 5 seconds (Change 5000 ms to any other value you want) */
  36. }