Buttons Modifier for ios.codevn.net

Always shows scroll-to-top button and adds a new scroll-to-download button

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 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.

ستحتاج إلى تثبيت إضافة مثل Stylus لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتتمكن من تثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

(لدي بالفعل مثبت أنماط للمستخدم، دعني أقم بتثبيته!)

// ==UserScript==
// @name         Buttons Modifier for ios.codevn.net
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Always shows scroll-to-top button and adds a new scroll-to-download button
// @author       Aligator
// @match        https://ios.codevn.net/*
// @grant        none
// @license      GNU GPLv3
// ==/UserScript==

(function() {
    'use strict';

    // Modify existing top button
    const existingTopBtn = document.querySelector('#top-btn');
    if (existingTopBtn) {
        existingTopBtn.style.opacity = '1';
        existingTopBtn.style.bottom = '4.4rem';
        existingTopBtn.style.visibility = 'visible';
    }

    // Create new scroll-to-download button
    const newBtn = document.createElement('a');
    newBtn.href = 'javascript:void(0);';
    newBtn.className = 'bottom-btn hidden-sm-down';
    newBtn.id = 'top-btn';
    newBtn.innerHTML = '<i aria-hidden="true" class="fa fa-arrow-up"></i>';
    newBtn.style.opacity = '1';
    newBtn.style.bottom = '0.9rem';
    newBtn.style.visibility = 'visible';
    newBtn.style.rotate = '180deg';

    // Add click event to scroll to download section
    newBtn.addEventListener('click', function() {
        const downloadSection = document.getElementById('download');
        if (downloadSection) {
            const downloadBottom = downloadSection.getBoundingClientRect().bottom;
            const windowHeight = window.innerHeight;
            const scrollTo = window.pageYOffset + downloadBottom - windowHeight;
            window.scrollTo({
                top: scrollTo,
                behavior: 'smooth'
            });
        }
    });

    // Insert the new button after the existing top button
    if (existingTopBtn) {
        existingTopBtn.parentNode.insertBefore(newBtn, existingTopBtn.nextSibling);
    }
})();