Atcoder Easy Accordion

Atcoderのアコーディオンメニューを、マウスのホバーで開けるようにします

La data de 13-04-2025. Vezi ultima versiune.

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         Atcoder Easy Accordion
// @namespace    http://tampermonkey.net/
// @version      1.1
// @description  Atcoderのアコーディオンメニューを、マウスのホバーで開けるようにします
// @author       Rac
// @license      MIT
// @match        https://atcoder.jp/*
// @exclude      /^https://atcoder\.jp/[^#?]*/json/
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    document.querySelectorAll(".nav > li:not(.pull-right)").forEach((element) => {
        element.addEventListener("mouseenter", () => {
            setTimeout(() => {
                element.classList.add("open");
            }, 10);
        });
        element.addEventListener("mouseleave", () => {
            element.classList.remove("open");
        });
    });
    {
        const element = document.getElementsByClassName("header-mypage_btn")[0];
        const element_ac = document.getElementsByClassName("header-mypage_detail")[0];
        if(element && element_ac) {
            let flag1 = false;
            let flag2 = false;
            element.addEventListener("mouseenter", () => {
                flag2 = false;
                if(!element.classList.contains("active")) {
                    setTimeout(() => {
                        if(!element.classList.contains("active")) element.click();
                    }, 10);
                }
            });
            element.addEventListener("mouseleave", () => {
                flag1 = true;
                setTimeout(() => {
                    if(flag1 && element.classList.contains("active")) element.click();
                }, 10);
            });
            element_ac.addEventListener("mouseenter", () => {
                flag1 = false;
                if(!element.classList.contains("active")) element.click();
            });
            element_ac.addEventListener("mouseleave", () => {
                flag2 = true;
                setTimeout(() => {
                    if(flag2 && element.classList.contains("active")) element.click();
                }, 10);
            });
        }
    }
})();