您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
This user script automatically detects Persian lyrics on YouTube Music and corrects their alignment by setting the text direction to right-to-left (RTL). It ensures Persian lines are properly displayed with RTL alignment and right text alignment, while keeping non-Persian lyrics in the default left-to-right (LTR) format. The script continuously monitors the page for dynamic lyric changes and applies the appropriate styling in real time.
// ==UserScript== // @name YT Music Persian Lyrics RTL Fixer // @namespace https://greasyfork.org/en/scripts/535068-yt-music-persian-lyrics-rtl-fixer // @match https://music.youtube.com/* // @version 1 // @description This user script automatically detects Persian lyrics on YouTube Music and corrects their alignment by setting the text direction to right-to-left (RTL). It ensures Persian lines are properly displayed with RTL alignment and right text alignment, while keeping non-Persian lyrics in the default left-to-right (LTR) format. The script continuously monitors the page for dynamic lyric changes and applies the appropriate styling in real time. // @author TheSina // @license MIT // ==/UserScript== function isPersian(text) { return /[\u0600-\u06FF]/.test(text); // Persian/Arabic character range } function updateLyricsDirection() { const lines = document.querySelectorAll('.blyrics-container > div'); lines.forEach(line => { const text = line.textContent || ''; if (isPersian(text)) { line.style.direction = 'rtl'; line.style.textAlign = 'right'; } else { line.style.direction = 'ltr'; line.style.textAlign = 'left'; } }); } // Run initially and on lyrics change const observer = new MutationObserver(updateLyricsDirection); observer.observe(document.body, { childList: true, subtree: true }); // Initial run updateLyricsDirection();