Greasy Fork is available in English.

Fourth Webcam Viewer

Aktiviert die vierte angeschlossene Webcam und öffnet ein eigenes Browserfenster, das das Bild der Kamera anzeigt.

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

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

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği indirebilmeniz için ayrıca Tampermonkey gibi bir eklenti kurmanız gerekmektedir.

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @name         Fourth Webcam Viewer
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Aktiviert die vierte angeschlossene Webcam und öffnet ein eigenes Browserfenster, das das Bild der Kamera anzeigt.
// @author       YourName
// @match        *://*/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    let selectedDeviceId = null;

    // Funktion zur Ermittlung der Kameras
    async function getCameras() {
        try {
            const devices = await navigator.mediaDevices.enumerateDevices();
            const videoDevices = devices.filter(device => device.kind === 'videoinput');

            if (videoDevices.length > 3) {
                selectedDeviceId = videoDevices[3].deviceId; // Vierte Kamera auswählen
                activateWebcam();
            } else {
                alert('Nicht genug Kameras angeschlossen.');
            }
        } catch (error) {
            console.error('Fehler beim Abrufen der Kameras:', error);
        }
    }

    // Webcam aktivieren und in eigenem Fenster anzeigen
    async function activateWebcam() {
        if (!selectedDeviceId) {
            console.log('Keine vierte Kamera verfügbar.');
            return;
        }

        try {
            const stream = await navigator.mediaDevices.getUserMedia({
                video: {
                    deviceId: { exact: selectedDeviceId },
                    width: { exact: 320 },
                    height: { exact: 240 },
                    frameRate: { max: 10 }
                },
                audio: false
            });

            // Neues Fenster öffnen und Stream anzeigen
            const cameraWindow = window.open('', '_blank', 'width=340,height=260');
            if (cameraWindow) {
                const cameraVideo = cameraWindow.document.createElement('video');
                cameraVideo.style.width = '320px';
                cameraVideo.style.height = '240px';
                cameraVideo.autoplay = true;
                cameraVideo.srcObject = stream;
                cameraWindow.document.body.appendChild(cameraVideo);

                cameraWindow.onbeforeunload = () => {
                    stream.getTracks().forEach(track => track.stop());
                };
            } else {
                alert('Pop-up Blocker deaktivieren, um das Kamerafenster zu öffnen.');
            }
        } catch (error) {
            console.error('Konnte die Webcam nicht aktivieren:', error);
        }
    }

    // Kameras ermitteln und aktivieren
    getCameras();
})();