GreasyFork - Leaderboard Shortcut

نقل خانة لوحة الصدارة بجانب أيقونة الحساب في الشريط العلوي

This script should not be not be installed directly. It is a library for other scripts to include with the meta directive // @require https://update.greasyfork.org/scripts/583355/1854911/GreasyFork%20-%20Leaderboard%20Shortcut.js

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         GreasyFork - Leaderboard Shortcut
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  نقل خانة لوحة الصدارة بجانب أيقونة الحساب في الشريط العلوي
// @author       You
// @match        https://greasyfork.org/*
// @grant        none
// @run-at       document-end
// ==/UserScript==

(function() {
    'use strict';

    // الانتظار قليلاً للتأكد من تحميل عناصر الصفحة
    setTimeout(() => {
        // 1. البحث عن رابط لوحة الصدارة في الموقع
        const leaderboardLink = document.querySelector('a[href*="/users/leaderboard"]');
        // 2. البحث عن عنصر الحساب الشخصي (مكان الوجه/اسم المستخدم)
        const userNav = document.querySelector('#nav-user-info, .user-profile-link');

        if (leaderboardLink && userNav) {
            // إنشاء عنصر قائمة جديد
            const li = document.createElement('li');
            li.style.display = 'inline-block';
            li.style.marginRight = '10px';
            li.style.marginLeft = '10px';
            li.style.verticalAlign = 'middle';

            // استنساخ الرابط وتعديل شكله ليناسب الشريط العلوي
            const newLink = leaderboardLink.cloneNode(true);
            newLink.style.fontWeight = 'bold';
            
            // إضافة الرابط داخل العنصر الجديد
            li.appendChild(newLink);

            // إدخال الرابط مباشرة قبل خانة المستخدم (بجانب الوجه)
            userNav.parentNode.insertBefore(li, userNav);
        }
    }, 500);
})();