cytube_set_page_title

再生中のタイトルをページタイトルにセット

Ajankohdalta 25.6.2020. Katso uusin versio.

// ==UserScript==
// @name         cytube_set_page_title
// @namespace    https://cytube.xyz/
// @version      1
// @description  再生中のタイトルをページタイトルにセット
// @author       utubo
// @match        https://cytube.xyz/*
// @grant        none
// ==/UserScript==

(function() {
  // jsが再読込されると多分2重で動いちゃうので既にoobseverが存在してたら破棄する
  var win = unsafeWindow || window;
  var obsever = win.GM_CURRENT_TITLE_OBSERVER;
  if (obsever) {
    obsever.disconnect();
  }
  // currentTitleが変更されたらページタイトルにコピーする
  var currentTitle = document.getElementById('currenttitle');
  var copyTitle = () => {
    var title = currentTitle.textContent;
    title = title.replace(win.__("Currently Playing: "), "");
    title += ' - ' + win.CHANNEL.opts.pagetitle;
    win.PAGETITLE = title;
    document.title = title;
  }
  obsever = new MutationObserver(copyTitle);
  obsever.observe(currentTitle, { childList: true });
  win.GM_CURRENT_TITLE_OBSERVER = obsever;
  
  // マーキー
  //setInterval(()=> { document.title = document.title.substring(1) + document.title.substring(0,1) }, 500);
})();