Universal Text Force-Select

Completely overrides selection blocks and link-dragging to allow text selection everywhere.

이 스크립트를 설치하려면 Tampermonkey, Greasemonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램을 설치해야 합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Userscripts와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 유저 스크립트 관리자 확장 프로그램이 필요합니다.

(이미 유저 스크립트 관리자가 설치되어 있습니다. 설치를 진행합니다!)

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

(이미 유저 스타일 관리자가 설치되어 있습니다. 설치를 진행합니다!)

// ==UserScript==
// @name        Universal Text Force-Select
// @version     2.1
// @author      Dunamis
// @namespace   https://dunamiss.xyz
// @license     MIT
// @description Completely overrides selection blocks and link-dragging to allow text selection everywhere.
// @match       *://*/*
// @grant       GM_addStyle
// @run-at      document-start
// ==/UserScript==

(function() {
    'use strict';

    // Force the browser to treat all text as selectable via CSS
    const css = `
        * {
            -webkit-user-select: text !important;
            -moz-user-select: text !important;
            -ms-user-select: text !important;
            user-select: text !important;
        }
        a {
            cursor: text !important;
        }
    `;

    // Inject CSS as early as possible
    if (typeof GM_addStyle !== 'undefined') {
        GM_addStyle(css);
    } else {
        const style = document.createElement('style');
        style.textContent = css;
        document.head.appendChild(style);
    }

    let isSelecting = false;
    let startX, startY;

    // Stop sites from "grabbing" the link to drag it as an icon
    document.addEventListener('dragstart', (e) => {
        e.preventDefault();
        return false;
    }, true);

    document.addEventListener('mousedown', (e) => {
        if (e.button === 0) { // Left click only
            startX = e.pageX;
            startY = e.pageY;
            isSelecting = false;
        }
    }, true);

    document.addEventListener('mousemove', (e) => {
        if (startX !== undefined) {
            const moveX = Math.abs(e.pageX - startX);
            const moveY = Math.abs(e.pageY - startY);
            if (moveX > 4 || moveY > 4) {
                isSelecting = true;
            }
        }
    }, true);

    document.addEventListener('click', (e) => {
        if (isSelecting) {
            // If the user was highlighting text, don't follow the link
            const target = e.target.closest('a');
            if (target) {
                e.preventDefault();
                e.stopImmediatePropagation();
            }
        }
        // Reset for next click
        startX = undefined;
        isSelecting = false;
    }, true);

})();