AudibleAccents

Enhances the audibility of accents, staccato, and marked notes in Musescore 4, with slightly slower tempo for slurred and marked notes.

当前为 2024-03-13 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         AudibleAccents
// @namespace    MusescoreEnhancements
// @version      1.1
// @description  Enhances the audibility of accents, staccato, and marked notes in Musescore 4, with slightly slower tempo for slurred and marked notes.
// @description:fr  Améliore l'audibilité des accents, des notes staccato et marquées dans Musescore 4, avec un tempo légèrement ralenti pour les notes liées et marquées.
// @description:de  Verbessert die Hörbarkeit von Akzenten, Staccato und markierten Noten in Musescore 4, mit leicht verlangsamtem Tempo für gebundene und markierte Noten.
// @description:it  Migliora l'udibilità di accenti, staccato e note contrassegnate in Musescore 4, con un tempo leggermente più lento per note legate e contrassegnate.
// @description:es  Mejora la audibilidad de acentos, staccato y notas marcadas en Musescore 4, con un tempo ligeramente más lento para notas ligadas y marcadas.
// @description:pt  Melhora a audibilidade de acentos, staccato e notas marcadas no Musescore 4, com um tempo ligeiramente mais lento para notas ligadas e marcadas.
// @description:zh  提高了Musescore 4中音符的音响效果,对于连音和标记音符,稍微降低了速度。
// @description:ja  Musescore 4のアクセント、スタッカート、マークされた音符の聞き取りやすさを向上させ、結び付けられた音符とマークされた音符の速度をわずかに遅くします。
// @description:ko  Musescore 4의 악센트, 스타카토 및 표시된 음표의 가청성을 향상시키고, 결합되고 표시된 음표의 속도를 약간 느리게 조정합니다.
// @description:lv  Uzlabo akcentu, stakato un atzīmēto notskaņu dzirdamību Musescore 4, nedaudz palēninot tempu sasaistītām un atzīmētām notīm.
// @author       YGL
// @license      GNU GPL 3.0
// @match        *://*/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    let scriptEnabled = false;

    const toggleScript = () => {
        scriptEnabled = !scriptEnabled;
        updateButton();
        if (scriptEnabled) enhanceNotes();
    };

    const createButton = () => {
        const button = document.createElement('button');
        button.id = 'audible-accents-button';
        button.style.cssText = 'position: fixed; top: 20px; right: 20px; width: 100px; height: 40px; border-radius: 20px; border: none; font-weight: bold; font-size: 14px; cursor: pointer; outline: none; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2), 0 6px 20px rgba(0, 0, 0, 0.19);';
        button.style.backgroundColor = scriptEnabled ? '#4CAF50' : '#2196F3';
        button.textContent = getButtonText();
        button.addEventListener('click', toggleScript);
        document.body.appendChild(button);
        adjustButtonPosition(button);
    };

    const updateButton = () => {
        const button = document.querySelector('#audible-accents-button');
        button.textContent = getButtonText();
        button.style.backgroundColor = scriptEnabled ? '#4CAF50' : '#2196F3';
        adjustButtonPosition(button);
    };

    const getButtonText = () => {
        const language = navigator.language.toLowerCase();
        const langText = {
            fr: ['Activé', 'Activer'],
            de: ['Aktiviert', 'Aktivieren'],
            it: ['Attivato', 'Attivare'],
            es: ['Activado', 'Activar'],
            pt: ['Ativado', 'Ativar'],
            zh: ['已激活', '激活'],
            ja: ['アクティブ', 'アクティブにする'],
            ko: ['활성화 됨', '활성화'],
            lv: ['Aktivizēts', 'Aktivizēt']
        };
        return scriptEnabled ? langText[language][0] || 'Activated' : langText[language][1] || 'Activate';
    };

    const adjustButtonPosition = button => {
        const boundingRect = button.getBoundingClientRect();
        const overlapElements = document.elementsFromPoint(boundingRect.left + boundingRect.width / 2, boundingRect.top + boundingRect.height / 2);

        overlapElements.forEach(element => {
            if (element !== button && element.tagName === 'BUTTON') {
                const elementRect = element.getBoundingClientRect();
                if (elementRect.bottom > boundingRect.top && elementRect.top < boundingRect.bottom &&
                    elementRect.right > boundingRect.left && elementRect.left < boundingRect.right) {
                    // There is overlap, adjust button position
                    button.style.top = `${elementRect.bottom + 10}px`;
                }
            }
        });
    };

    const enhanceNotes = () => {
        // Your code to enhance notes here
    };

    const waitForMusescore = () => {
        if (typeof curScore === 'undefined') {
            setTimeout(waitForMusescore, 100);
        } else {
            createButton();
        }
    };

    waitForMusescore();
})();