Faster Sounter

Controla a reprodução no sounter.com usando as teclas "a", "d" e "w" e copia a frase atual da música ou o texto selecionado quando pressiona Ctrl + C.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Faster Sounter
// @namespace    http://tampermonkey.net/
// @version      2.0
// @description  Controla a reprodução no sounter.com usando as teclas "a", "d" e "w" e copia a frase atual da música ou o texto selecionado quando pressiona Ctrl + C.
// @author       Kycoft
// @match        *://sounter.com/*
// @grant        none
// @license MIT
// ==/UserScript==

(function() {
    'use strict';

    // Função para obter o texto selecionado na página
    function obterTextoSelecionado() {
        return window.getSelection().toString();
    }

    // Função para obter a frase atual da música
    function obterFraseAtual() {
        var fraseAtualElemento = document.querySelector('.Karaoke_highlighted___s3Zt .Karaoke_completePhrase__aXQmO');

        if (fraseAtualElemento) {
            return fraseAtualElemento.textContent.trim();
        } else {
            return "Frase não encontrada";
        }
    }

    // Função para copiar o texto para a área de transferência
    function copiarTextoParaAreaDeTransferencia(texto) {
        var textarea = document.createElement('textarea');
        textarea.value = texto;
        document.body.appendChild(textarea);
        textarea.select();
        document.execCommand('copy');
        document.body.removeChild(textarea);
    }

    // Função para simular clique no elemento
    function simularClique(elemento) {
        if (elemento) {
            var eventoClique = new MouseEvent('click', {
                bubbles: true,
                cancelable: true,
                view: window
            });
            elemento.dispatchEvent(eventoClique);
        }
    }

    // Ouvinte de evento para Ctrl + C, "a", "d" e "w"
    document.addEventListener('keydown', function (event) {
        // Elemento "SkipPrevious" (tecla "a")
        if (event.key === 'a') {
            var skipPreviousIcon = document.querySelector('[data-testid="SkipPreviousIcon"]');
            simularClique(skipPreviousIcon);
        }

        // Elemento "SkipNext" (tecla "d")
        if (event.key === 'd') {
            var skipNextIcon = document.querySelector('[data-testid="SkipNextIcon"]');
            simularClique(skipNextIcon);
        }

        // Elemento "TranslateIcon" (tecla "w")
        if (event.key === 'w') {
            var translateIcon = document.querySelector('[data-testid="TranslateIcon"]');
            simularClique(translateIcon);
        }

        // Ctrl + C para copiar frase atual ou texto selecionado
        if (event.ctrlKey && event.key === 'c') {
            var textoSelecionado = obterTextoSelecionado();

            if (textoSelecionado) {
                // Se houver texto selecionado, copie esse texto
                copiarTextoParaAreaDeTransferencia(textoSelecionado);
                console.log('Texto selecionado copiado: ' + textoSelecionado);
            } else {
                // Caso contrário, copie a frase atual da música
                var fraseAtual = obterFraseAtual();
                copiarTextoParaAreaDeTransferencia(fraseAtual);
                console.log('Frase atual copiada: ' + fraseAtual);
            }
        }
    });

})();