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

  1. // ==UserScript==
  2. // @name AudibleAccents
  3. // @namespace MusescoreEnhancements
  4. // @version 1.1
  5. // @description Enhances the audibility of accents, staccato, and marked notes in Musescore 4, with slightly slower tempo for slurred and marked notes.
  6. // @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.
  7. // @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.
  8. // @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.
  9. // @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.
  10. // @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.
  11. // @description:zh 提高了Musescore 4中音符的音响效果,对于连音和标记音符,稍微降低了速度。
  12. // @description:ja Musescore 4のアクセント、スタッカート、マークされた音符の聞き取りやすさを向上させ、結び付けられた音符とマークされた音符の速度をわずかに遅くします。
  13. // @description:ko Musescore 4의 악센트, 스타카토 및 표시된 음표의 가청성을 향상시키고, 결합되고 표시된 음표의 속도를 약간 느리게 조정합니다.
  14. // @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.
  15. // @author YGL
  16. // @license GNU GPL 3.0
  17. // @match *://*/*
  18. // @grant none
  19. // ==/UserScript==
  20.  
  21. (function() {
  22. 'use strict';
  23.  
  24. let scriptEnabled = false;
  25.  
  26. const toggleScript = () => {
  27. scriptEnabled = !scriptEnabled;
  28. updateButton();
  29. if (scriptEnabled) enhanceNotes();
  30. };
  31.  
  32. const createButton = () => {
  33. const button = document.createElement('button');
  34. button.id = 'audible-accents-button';
  35. 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);';
  36. button.style.backgroundColor = scriptEnabled ? '#4CAF50' : '#2196F3';
  37. button.textContent = getButtonText();
  38. button.addEventListener('click', toggleScript);
  39. document.body.appendChild(button);
  40. adjustButtonPosition(button);
  41. };
  42.  
  43. const updateButton = () => {
  44. const button = document.querySelector('#audible-accents-button');
  45. button.textContent = getButtonText();
  46. button.style.backgroundColor = scriptEnabled ? '#4CAF50' : '#2196F3';
  47. adjustButtonPosition(button);
  48. };
  49.  
  50. const getButtonText = () => {
  51. const language = navigator.language.toLowerCase();
  52. const langText = {
  53. fr: ['Activé', 'Activer'],
  54. de: ['Aktiviert', 'Aktivieren'],
  55. it: ['Attivato', 'Attivare'],
  56. es: ['Activado', 'Activar'],
  57. pt: ['Ativado', 'Ativar'],
  58. zh: ['已激活', '激活'],
  59. ja: ['アクティブ', 'アクティブにする'],
  60. ko: ['활성화 됨', '활성화'],
  61. lv: ['Aktivizēts', 'Aktivizēt']
  62. };
  63. return scriptEnabled ? langText[language][0] || 'Activated' : langText[language][1] || 'Activate';
  64. };
  65.  
  66. const adjustButtonPosition = button => {
  67. const boundingRect = button.getBoundingClientRect();
  68. const overlapElements = document.elementsFromPoint(boundingRect.left + boundingRect.width / 2, boundingRect.top + boundingRect.height / 2);
  69.  
  70. overlapElements.forEach(element => {
  71. if (element !== button && element.tagName === 'BUTTON') {
  72. const elementRect = element.getBoundingClientRect();
  73. if (elementRect.bottom > boundingRect.top && elementRect.top < boundingRect.bottom &&
  74. elementRect.right > boundingRect.left && elementRect.left < boundingRect.right) {
  75. // There is overlap, adjust button position
  76. button.style.top = `${elementRect.bottom + 10}px`;
  77. }
  78. }
  79. });
  80. };
  81.  
  82. const enhanceNotes = () => {
  83. // Your code to enhance notes here
  84. };
  85.  
  86. const waitForMusescore = () => {
  87. if (typeof curScore === 'undefined') {
  88. setTimeout(waitForMusescore, 100);
  89. } else {
  90. createButton();
  91. }
  92. };
  93.  
  94. waitForMusescore();
  95. })();