LeetCode显示的多编程语言代码区域增加水平滚动条

Add a horizontal scrollbar to the div container with class 'bg-layer-2'

Stan na 13-01-2024. Zobacz najnowsza wersja.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name         LeetCode显示的多编程语言代码区域增加水平滚动条
// @name:zh-TW   LeetCode顯示的多程式設計語言程式碼區域新增水准滾動條
// @name:en      LeetCode Horizontal Scroll for Multi Programming Language Code Div Container
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description:en Add a horizontal scrollbar to the div container with class 'bg-layer-2'
// @description:zh-tw 將水准滾動條添加到類為“bg-layer-2”的div容器中
// @description  Add a horizontal scrollbar to the div container with class 'bg-layer-2'
// @author       aspen138
// @match        https://leetcode.cn/*
// @match        https://leetcode.com/*
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    // Add your JavaScript code here
    var css = `
        .bg-layer-2 {
            overflow-x: auto; /* Trigger horizontal scrolling */
            display: flex; /* Ensure the items are in a flex row */
            white-space: nowrap; /* Prevent wrapping of items */
        }
        .bg-layer-2 > div {
            flex: 0 0 auto; /* Prevent flex items from shrinking */
            display: inline-block; /* Treat each div as an inline block */
        }
    `;

    // Create a style element
    var style = document.createElement('style');
    style.type = 'text/css';
    style.appendChild(document.createTextNode(css));
    document.head.appendChild(style);
})();