统计选中字符数量(Powered By GPT) Character Count Tracker

Tracks the number of copied characters and displays it on the webpage

目前为 2023-06-18 提交的版本。查看 最新版本

// ==UserScript==
// @name       统计选中字符数量(Powered By GPT) Character Count Tracker
// @namespace  http://your.namespace.com
// @version    1.0
// @description  Tracks the number of copied characters and displays it on the webpage
// @match      http://*/*
// @match      https://*/*
// @grant      none
// author      韩立
// ==/UserScript==

(function() {
  // Create a container element to hold the character count
  var charCountContainer = document.createElement('div');
  charCountContainer.style.cssText = 'position: fixed; bottom: 10px; right: 10px;';

  // Create a span element to display the character count
  var charCountDisplay = document.createElement('span');
  charCountDisplay.style.cssText = 'background-color: #fff; padding: 5px;';

  // Add the display element to the container
  charCountContainer.appendChild(charCountDisplay);

  // Append the container to the document body
  document.body.appendChild(charCountContainer);

  var previousCharCount = 0;

  function updateCharCount() {
    var selectedText = window.getSelection().toString();
    var charCount = selectedText.length;

    if (charCount > 0) {
      // Display the character count if text is selected
      charCountDisplay.textContent = '选中字符: ' + charCount;
      charCountContainer.style.display = 'block';

      if (charCount !== previousCharCount) {
        // Character count has changed, do something here if needed
        previousCharCount = charCount;
      }
    } else {
      // Hide the character count if no text is selected
      charCountContainer.style.display = 'none';
      previousCharCount = 0;
    }
  }

  // Listen for selection change events
  document.addEventListener('mouseup', updateCharCount);
  document.addEventListener('touchend', updateCharCount);
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址