Greasy Fork 支持简体中文。

NightBot-AutoDJ song-name helper

Make craftwar's obs plugin (https://craftwarblog.blogspot.com/2018/01/obs-plugin-playing-song.html) able to get NightBot-AutoDJ song name.

  1. // ==UserScript==
  2. // @author craftwar
  3. // @name NightBot-AutoDJ song-name helper
  4. // @description Make craftwar's obs plugin (https://craftwarblog.blogspot.com/2018/01/obs-plugin-playing-song.html) able to get NightBot-AutoDJ song name.
  5. // @copyright 2020, craftwar (https://craftwarblog.blogspot.com/)
  6. // @license GPL-3.0-or-later; https://www.gnu.org/licenses/gpl-3.0.txt
  7. // @homepageURL https://github.com/craftwar/userscript/tree/master/NightBot-song-name-helper
  8. // @version 0.1.20201005
  9. // @namespace github.com.craftwar
  10. // @match https://beta.nightbot.tv/song_requests*
  11. // @match https://nightbot.tv/song_requests*
  12. // @grant none
  13. // @run-at document-end
  14. // ==/UserScript==
  15.  
  16. 'use strict';
  17. (() => {
  18. const body_observer = new MutationObserver( (record, observer)=> {
  19. const element = document.querySelector(".current-track > h4:first-child > strong:first-child").childNodes[0];
  20. if (element) {
  21. observer.disconnect();
  22.  
  23. const song_observer = new MutationObserver( ()=> {
  24. document.title = element.wholeText + " - YouTube";
  25. });
  26. song_observer.observe(element, { characterData: true });
  27. }
  28. });
  29.  
  30. const body_element = document.querySelector("body");
  31. body_observer.observe(body_element, { subtree: true, childList: true });
  32. })();