cytube_set_page_title

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

目前為 2020-06-25 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==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.AUTO_PAGE_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.AUTO_PAGE_TITLE_OBSERVER = obsever;
  
  // マーキー
  //setInterval(()=> { document.title = document.title.substring(1) + document.title.substring(0,1) }, 500);
})();