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 提交的版本,檢視 最新版本

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

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

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

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

你需要先安裝一款使用者腳本管理器擴展,比如 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();
})();