Video Screenshot

alabileceğin en kaliteli görüntüyü alır.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Video Screenshot
// @namespace    http://tampermonkey.net/
// @version      1.1
// @description  alabileceğin en kaliteli görüntüyü alır.
// @author       Mustafa Hakan
// @match        *://*/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    function takeScreenshot() {
        // 1. Sayfadaki video elementini bul
        const video = document.querySelector('video');
        
        if (!video) {
            alert("Sayfada oynatılan bir video bulunamadı!");
            return;
        }

        try {
            // 2. Gizli bir Canvas oluştur (Videonun orijinal boyutlarında)
            const canvas = document.createElement('canvas');
            canvas.width = video.videoWidth;
            canvas.height = video.videoHeight;
            
            // 3. Videonun o anki karesini Canvas'a çiz
            const ctx = canvas.getContext('2d');
            ctx.drawImage(video, 0, 0, canvas.width, canvas.height);
            
            // 4. Canvas'ı PNG verisine dönüştür
            const imageData = canvas.toDataURL('image/png');
            
            // 5. Otomatik indirme bağlantısı oluştur
            const downloadLink = document.createElement('a');
            const timestamp = new Date().toLocaleTimeString().replace(/:/g, '-');
            downloadLink.download = `nm_EkranGoruntusu_${timestamp}.png`;
            downloadLink.href = imageData;
            downloadLink.click();
            
            console.log("Ekran görüntüsü başarıyla alındı.");
        } catch (err) {
            console.error("Hata:", err);
            alert("Güvenlik (CORS) nedeniyle bu sitede ekran görüntüsü alınamıyor.");
        }
    }

    // ARAYÜZE BUTON EKLE (Önceki toolbarına ekliyoruz)
    const screenshotBtn = document.createElement('button');
    screenshotBtn.innerText = '📸 Kareyi Yakala';
    screenshotBtn.className = 'm-btn'; // Daha önce tanımladığın buton stili
    screenshotBtn.onclick = takeScreenshot;

    // Toolbar'ı bul ve butonu ekle
    const toolbar = document.getElementById('toolbar');
    if (toolbar) {
        toolbar.appendChild(screenshotBtn);
    }
})();