Netflix - Extended Titles

Adds the title name to the head.title property (tab display name)

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name            Netflix - Extended Titles
// @description     Adds the title name to the head.title property (tab display name)
// @author          Archangel1C
// @version         0.1
// @match           http*://www.netflix.com/title/*
// @run-at          document-start
// @grant           none
// @compatible      chrome
// @license         GPL-3.0-only
// @namespace       https://github.com/Archangel1C
// @contributionURL https://flattr.com/@Archangel1C
// ==/UserScript==
//
// Sources/Influences:

(function extendTitles() {
    'use strict';

    function domListener(e) {
//      console.log(`[${GM_info.script.name}] DOMNodeInserted: relatedNode=${e.relatedNode}`);
//      console.log(e.relatedNode);
        if (e.relatedNode.classList.contains("previewModal--player-titleTreatment")) {
//          console.log(`[${GM_info.script.name}] DOMNodeInserted: relatedNode=${e.relatedNode}`);
//          console.log(e);
            this.titleNameNodeAdded = true;
            var titleTreatmentLogo = e.relatedNode.querySelector("img.previewModal--player-titleTreatment-logo");
            if (titleTreatmentLogo == null) {
                console.log(`[${GM_info.script.name}] could not find title element`);
                return;
            }
            console.log(`[${GM_info.script.name}] extending title with name "${titleTreatmentLogo.title}"`);
            document.title = document.title + ": " + titleTreatmentLogo.title;
        } else if (e.relatedNode.classList.contains("detail-modal-container")) {
//          console.log(`[${GM_info.script.name}] DOMNodeInserted: relatedNode=${e.relatedNode}`);
//          console.log(e);
            this.titleTypeNodeAdded = true;
            var titleType = e.relatedNode.querySelector("div.videoMetadata--second-line > span.duration")
            if (titleType == null) {
                console.log(`[${GM_info.script.name}] could not find title type`);
            } else {
                console.log(`[${GM_info.script.name}] extending title with type "${titleType.textContent}"`);
                document.title = document.title + " (" + titleType.textContent + ")";
            }
        }

        if (this.titleNameNodeAdded && this.titleTypeNodeAdded) {
            console.log(`[${GM_info.script.name}] removing DOMNodeInserted listener ${domListener.name}`);
            document.removeEventListener("DOMNodeInserted", domListener);
        }
    }
    domListener.titleNameNodeAdded = false;
    domListener.titleTypeNodeAdded = false;

    console.log(`[${GM_info.script.name}] adding DOMNodeInserted listener ${domListener.name}`);
    document.addEventListener("DOMNodeInserted", domListener);
})();