您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Fixes mixed-direction paragraphs on old.reddit.com by adding the dir="rtl" attribute
// ==UserScript== // @name Right-to-Left Paragraph Fixer // @namespace tampermonkey // @version 1.0 // @description Fixes mixed-direction paragraphs on old.reddit.com by adding the dir="rtl" attribute // @match https://old.reddit.com/* // @grant none // ==/UserScript== (function() { 'use strict'; // Identify paragraphs based on their text content const paragraphs = document.querySelectorAll('div.md'); // Check if the paragraph contains mixed direction text patterns for (const paragraph of paragraphs) { if ( paragraph.textContent.match(/[\u0590-\u07FF]|[\u200E-\u200F]|[\u202A-\u202E]|[\uFB51-\uFD3F]|[\uFD3F-\uFD8F]/g) && paragraph.textContent.match(/[\u0000-\u007F]|\u0080-\u04FF]|[\u0500-\u058F]|[\u0700-\u07FF]|[\u0900-\u0D7F]|[\u1200-\u137F]|[\u1400-\u197F]|[\u2000-\u206F]|[\u2070-\u2BFF]|[\u2C00-\u2D7F]|[\u2E00-\u2FFF]|[\u3000-\u30FF]|[\u3400-\u4D7F]|[\u4E00-\u9FFF]|[\uA000-\uA4FF]|[\uA600-\uA9FF]|[\uAC00-\uD7FF]|[\uD800-\uDB7F]|[\uDB80-\uDBFF]|[\uDC00-\uDFFF]|[\uE000-\uE8FF]|[\uEE00-\uEEFF]|[\uEF00-\uFE0F]|[\uFE10-\uFE19]|[\uFE20-\uFE2F]|[\uFE30-\uFE4F]|[\uFE50-\uFE6F]|[\uFE70-\uFEFF]|[\uFF00-\uFFEF]/g) ) { // Add the dir="rtl" attribute to the paragraph paragraph.setAttribute('dir', 'rtl'); } } })();