Sorting videos on YouTube

Sorting videos on YouTube using the floating button

スクリプトをインストールするには、Tampermonkey, GreasemonkeyViolentmonkey のような拡張機能のインストールが必要です。

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

スクリプトをインストールするには、TampermonkeyViolentmonkey のような拡張機能のインストールが必要です。

スクリプトをインストールするには、TampermonkeyUserscripts のような拡張機能のインストールが必要です。

このスクリプトをインストールするには、Tampermonkeyなどの拡張機能をインストールする必要があります。

このスクリプトをインストールするには、ユーザースクリプト管理ツールの拡張機能をインストールする必要があります。

(ユーザースクリプト管理ツールは設定済みなのでインストール!)

このスタイルをインストールするには、Stylusなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus などの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus tなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

(ユーザースタイル管理ツールは設定済みなのでインストール!)

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください
// ==UserScript==
// @name         Sorting videos on YouTube
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  Sorting videos on YouTube using the floating button
// @author       You
// @match        https://www.youtube.com/*
// @grant        none
// @license MIT
// ==/UserScript==

(function() {
    'use strict';

    // Создаем плавающую кнопку
    const button = document.createElement('button');
    button.innerHTML = 'Reverse';
    button.style.position = 'fixed';
    button.style.bottom = '20px';
    button.style.right = '20px';
    button.style.zIndex = 1000;
    button.style.padding = '10px 15px';
    button.style.fontSize = '14px';
    button.style.cursor = 'pointer';
    document.body.appendChild(button);

    // Функция для переключения стилей
    function toggleStyles() {
        const styleElement = document.getElementById('reverse-styles');
        if (styleElement) {
            styleElement.remove();
        } else {
            const style = document.createElement('style');
            style.id = 'reverse-styles';
            style.innerHTML = `
                #contents.ytd-rich-grid-renderer {
                    width: 100%;
                    padding-top: 24px;
                    display: flex;
                    flex-wrap: wrap;
                    justify-content: flex-start;
                    flex-direction: column-reverse;
                }
                #contents {
                    flex-direction: row-reverse;
                }
            `;
            document.head.appendChild(style);
        }
    }

    // Добавляем обработчик событий клика на кнопку
    button.addEventListener('click', toggleStyles);
})();