IMDB - Reel Faces

Use some 'reel' magic on any 'Full Credits' page with the 'Reel Faces' Checkbox (When checked, It hides cast/crew that lack a profile picture) – because every movie deserves a picture-perfect cast!

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name        IMDB - Reel Faces
// @namespace   NooScripts
// @match       https://www.imdb.com/*/fullcredits*
// @match       https://www.imdb.com/
// @grant       none
// @version     1.0
// @author      NooScripts
// @description Use some 'reel' magic on any 'Full Credits' page with the 'Reel Faces' Checkbox (When checked, It hides cast/crew that lack a profile picture) – because every movie deserves a picture-perfect cast!
// @license     MIT
// ==/UserScript==

(function() {
    'use strict';

    function toggleElements(className, imgSrc, hideNoface) {
        const elements = document.querySelectorAll(`.${className} img[src="${imgSrc}"]`);
        elements.forEach(element => {
            const parent = element.closest(`.${className}`);
            if (parent) {
                parent.classList.toggle('hidden', hideNoface);
            }
        });
    }

    function addContainer() {
        const targetElement = document.querySelector('.subpage_title_block__right-column');
        if (!targetElement) {
            console.error('Target element not found.');
            return;
        }

        const container = document.createElement('div');
        container.style.display = 'flex';
        container.style.alignItems = 'center';

        const checkbox = document.createElement('input');
        checkbox.type = 'checkbox';
        checkbox.id = 'hideNofaceCheckbox';

        const label = document.createElement('label');
        label.innerHTML = 'Reel Faces';
        label.setAttribute('for', 'hideNofaceCheckbox');
        label.style.color = '#000';
        label.style.background = '#f5c518';
        label.style.padding = '2.5px';


        checkbox.addEventListener('change', function() {
            const isChecked = this.checked;
            toggleElements('odd', 'https://m.media-amazon.com/images/S/sash/N1QWYSqAfSJV62Y.png', isChecked);
            toggleElements('even', 'https://m.media-amazon.com/images/S/sash/N1QWYSqAfSJV62Y.png', isChecked);
            checkbox.style.backgroundColor = isChecked ? 'black' : 'transparent';
        });

        // Update checkbox styles
        checkbox.style.width = '20px';
        checkbox.style.height = '20px';
        checkbox.style.backgroundColor = 'transparent';
        checkbox.style.border = '1px solid white';
        checkbox.style.borderRadius = '3px';
        checkbox.style.cursor = 'pointer';
        checkbox.style.marginRight = '5px';

        // Append checkbox, label, and container to the target element
        container.appendChild(checkbox);
        container.appendChild(label);
        targetElement.appendChild(container);
    }

    addContainer();
})();