Buttons Modifier for ios.codevn.net

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला 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);
    }
})();