Selecting checkboxes on mouse-over

"The script performs checkboxes on the site page, over which you move the mouse cursor. Holding down the ALT key and hovering the cursor over any checkbox will select all checkboxes or uncheck all checkboxes that were previously selected."

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name            Selecting checkboxes on mouse-over
// @name:ru         Выбор чек-боксов при наведении курсора
// @description     "The script performs checkboxes on the site page, over which you move the mouse cursor. Holding down the ALT key and hovering the cursor over any checkbox will select all checkboxes or uncheck all checkboxes that were previously selected."
// @description:ru  "Скрипт выполняет установку флажков в чек-боксах на странице сайта, над которыми проводишь курсором мыши. При удерживании клавиши ALT и наведении курсора на любой чек-бокс, все чек-боксы будут выбраны или сняты все флажки со всех чек-боксов, которые были выбраны ранее."
// @namespace       https://greasyfork.org/users/1221433
// @icon            https://vse-tv.net/img/scripts/check_boxes.png
// @author          Sitego
// @date            2023-12-02
// @version         1.1
// @match           *://*/*
// @grant           none
// @license         MIT
// ==/UserScript==

(function () {
    var checkboxes = document.querySelectorAll('input[type="checkbox"]');

    checkboxes.forEach(function (checkbox) {
        checkbox.addEventListener('mouseover', function (event) {
            if (event.altKey) {
                checkboxes.forEach(function (cb) {
                    cb.checked = !cb.checked;
                });
            } else {
                if (!checkbox.checked) {
                    checkbox.checked = true;
                } else {
                    checkbox.checked = false;
                }
            }
        });
    });
})();