Copy Transcript Text Button for Coursera

Adds a button to copy transcript text to clipboard on Coursera course video pages

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

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 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.

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

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         Copy Transcript Text Button for Coursera
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Adds a button to copy transcript text to clipboard on Coursera course video pages
// @author       Your Name
// @match        https://*.coursera.org/learn/*/lecture/*
// @grant        none
// @run-at       document-end
// @license     MIT
// ==/UserScript==

(function() {
    'use strict';

    // Function to copy text to clipboard
    function copyToClipboard(text) {
       text = text.slice(203);
        const textArea = document.createElement('textarea');
        textArea.value = text;
        document.body.appendChild(textArea);
        textArea.select();
        document.execCommand('copy');
        document.body.removeChild(textArea);
    }

    // Function to add the copy button
    function addButton() {
        // Ensure the transcript lighter element exists


        // Create button element
        const button = document.createElement('button');
        button.textContent = 'Copy Transcript Text';
        button.style.position = 'absolute';
        button.style.top = '10px';
        button.style.right = '150px';
        button.style.padding = '10px';
        button.style.backgroundColor = '#007bff';
        button.style.color = '#fff';
        button.style.border = 'none';
        button.style.borderRadius = '5px';
        button.style.cursor = 'pointer';
        button.style.zIndex = '1000';

        // Add button to the page
        document.body.appendChild(button);

        var transcriptLighter
        // Add click event listener to the button
        button.addEventListener('click', () => {
        if (!transcriptLighter) {
            transcriptLighter = document.querySelector('div[id$="-panel-TRANSCRIPT"]');
        }
            const text = transcriptLighter.textContent.trim();
            if (text) {
                copyToClipboard(text);
            } 
        });
    }

    // Wait until the page is fully loaded
    window.addEventListener('load', () => {
        setTimeout(addButton,2000); // Delay to ensure the transcript is loaded
    });

})();