Kimi.com RTL

يمنع النص من الانتقال لسطر جديد بعد الرقم/النقطة في القوائم

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği yüklemek için Tampermonkey gibi bir uzantı yüklemeniz gerekir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği indirebilmeniz için ayrıca Tampermonkey gibi bir eklenti kurmanız gerekmektedir.

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

Bu stili yüklemek için Stylus gibi bir uzantı yüklemeniz gerekir.

Bu stili yüklemek için Stylus gibi bir uzantı kurmanız gerekir.

Bu stili yükleyebilmek için Stylus gibi bir uzantı yüklemeniz gerekir.

Bu stili yüklemek için bir kullanıcı stili yöneticisi uzantısı yüklemeniz gerekir.

Bu stili yüklemek için bir kullanıcı stili yöneticisi uzantısı kurmanız gerekir.

Bu stili yükleyebilmek için bir kullanıcı stili yöneticisi uzantısı yüklemeniz gerekir.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @name         Kimi.com RTL
// @namespace    http://tampermonkey.net/
// @version      2.2
// @description  يمنع النص من الانتقال لسطر جديد بعد الرقم/النقطة في القوائم
// @author       أنت
// @match        https://www.kimi.com/*
// @match        http://www.kimi.com/*
// @grant        GM_addStyle
// @run-at       document-end
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    // ========== 1. تطبيق dir="auto" على العناصر النصية (كما كان) ==========
    function applyDirAuto(element) {
        const textSelectors = [
            'p', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6',
            'td', 'th', 'blockquote', 'pre', 'code',
            'span', 'a', 'button', 'label', 'figcaption',
            'caption', 'address', 'dt', 'dd', 'legend',
            'optgroup', 'option', 'select', 'textarea',
            'input[type="text"]', 'input[type="search"]',
            'div:not(:has(> *))'
        ];
        const elements = element.querySelectorAll(textSelectors.join(','));
        elements.forEach(el => {
            if (!el.hasAttribute('dir')) {
                el.setAttribute('dir', 'auto');
            }
        });
    }
    applyDirAuto(document.body);

    const observer = new MutationObserver(mutations => {
        mutations.forEach(mutation => {
            mutation.addedNodes.forEach(node => {
                if (node.nodeType === 1) applyDirAuto(node);
            });
        });
    });
    observer.observe(document.body, { childList: true, subtree: true });

    // ========== 2. إصلاح القوائم (li) ومنع النص من النزول لسطر جديد ==========
    GM_addStyle(`
        li {
            direction: rtl !important;           /* الرقم في أقصى اليمين */
            text-align: right !important;         /* محاذاة النص لليمين */
            list-style-position: inside !important; /* الرقم داخل العنصر */
            padding: 0 !important;
            margin: 0 !important;
            white-space: normal !important;       /* السماح بالتفاف النص طبيعياً */
            display: list-item !important;        /* الحفاظ على السلوك الافتراضي */
        }

        /* ضبط padding للقوائم نفسها */
        ol, ul {
            padding-right: 1.5em !important;
            padding-left: 0 !important;
        }

        /* منع أي عنصر داخل li من أخذ سطر كامل (إجباره ليكون inline) */
        li > * {
            display: inline !important;            /* يجعل الأبناء المباشرين في نفس السطر */
            vertical-align: baseline !important;
        }

        /* معالجة عناصر معروفة قد تكون block ونريدها inline */
        li > div, li > p, li > h1, li > h2, li > h3, li > h4, li > h5, li > h6, li > blockquote {
            display: inline !important;
        }

        /* السماح للنص داخل الـ li باستخدام dir="auto" الذي طبقناه سابقاً */
        li * {
            direction: auto !important;
            unicode-bidi: normal !important;
        }

        /* ضبط الـ marker (الرقم/النقطة) ليكون متوافقاً مع RTL */
        li::marker {
            unicode-bidi: isolate;
            text-align: right;
        }
    `);

    // تأكيد أن li لها dir="rtl" بعد تطبيق dir="auto"
    function fixListItems() {
        document.querySelectorAll('li').forEach(li => {
            li.setAttribute('dir', 'rtl');
        });
    }
    setTimeout(fixListItems, 150);

    const listObserver = new MutationObserver(mutations => {
        mutations.forEach(mutation => {
            mutation.addedNodes.forEach(node => {
                if (node.nodeType === 1) {
                    if (node.matches && node.matches('li')) node.setAttribute('dir', 'rtl');
                    node.querySelectorAll && node.querySelectorAll('li').forEach(li => li.setAttribute('dir', 'rtl'));
                }
            });
        });
    });
    listObserver.observe(document.body, { childList: true, subtree: true });
})();