Open Link Under Mouse - Ctrl+Shift+Z

Mở liên kết tại vị trí con trỏ chuột hiện tại trong thẻ mới bằng Ctrl + Shift + Z

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         Open Link Under Mouse - Ctrl+Shift+Z
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Mở liên kết tại vị trí con trỏ chuột hiện tại trong thẻ mới bằng Ctrl + Shift + Z
// @author       Bạn
// @match        *://*/*
// @grant        none
// ==/UserScript==

(function () {
    'use strict';

    let currentElement = null;

    // Cập nhật phần tử dưới chuột
    document.addEventListener('mousemove', function (e) {
        currentElement = document.elementFromPoint(e.clientX, e.clientY);
    });

    // Lắng nghe tổ hợp phím Ctrl + Shift + Z
    document.addEventListener('keydown', function (e) {
        if (e.ctrlKey && e.shiftKey && e.code === 'KeyZ') {
            if (!currentElement) return;

            // Tìm phần tử là link gần nhất từ vị trí chuột
            let el = currentElement;
            while (el && el !== document.body) {
                if (el.tagName === 'A' && el.href) {
                    window.open(el.href, '_blank');
                    break;
                }
                el = el.parentElement;
            }
        }
    });
})();