网页选中文本去除光标只显示鼠标

发布时间 2023-08-28 10:59:59作者: 你的-昵称

在浏览网页文字时,鼠标放至文字附近,会自动变为光标。
使用以下tempormonkey脚本,取消自动变为光标,仍然显示指针鼠标。

// ==UserScript==
// @name         No_Cursor
// @namespace    none
// @version      1
// @description  Disables user from selecting text on any web page by manipulating the CSS user-select property
// @match        *://*/*
// @grant        GM_addStyle
// ==/UserScript==

GM_addStyle("* { -webkit-user-select:text !important; user-select:text !important; cursor:default !important }");
(function(){
    'use strict';
    //指定需要设置背景图片的选择器
    var selector = 'body';
    //
    var backgroundUrl = "D:/HelloL/Pictures/practice.jpg";
    //设置背景图片
    var element = document.querySelector(selector);
    if (element) {
        element.style.backgroundImage = 'url("'+backgroundUrl+'")';
    }
})();

//第一个属性启用文本选择,在移动设备上也可以使用手指选择文本。
//第二个属性允许用户在网页上选择和复制文本。样式将保留光标,但不会显示文本光标。
//第三个属性显示默认鼠标样式。```