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와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Userscripts와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 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);
    }
})();