Netflix - Extended Titles

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

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

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

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

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

你需要先安裝一款使用者腳本管理器擴展,比如 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);
})();