您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Greasy Fork is available in English.
在网页上选中文字时,通过浮层显示字数
// ==UserScript== // @name 字数统计浮层 // @namespace http://tampermonkey.net/ // @version 0.1 // @license MIT // @description 在网页上选中文字时,通过浮层显示字数 // @author shanhai2049 // @match *://*/* // @grant none // ==/UserScript== (function() { 'use strict'; // 创建浮层元素 const floatDiv = document.createElement('div'); floatDiv.style.cssText = 'position: absolute; z-index: 1000; padding: 5px; background: white; border: 1px solid black; border-radius: 4px; font-size: 12px; display: none;'; document.body.appendChild(floatDiv); document.addEventListener('mouseup', function(e) { const selectedText = window.getSelection().toString(); if (selectedText.length > 0) { floatDiv.textContent = `字符数: ${selectedText.length}`; floatDiv.style.display = 'block'; floatDiv.style.left = `${e.pageX- 80}px` ; floatDiv.style.top = `${e.pageY+15}px`; } else { floatDiv.style.display = 'none'; } }); })();