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

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

目前為 2023-06-18 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name       统计选中字符数量(Powered By GPT) Character Count Tracker
// @namespace  https://greasyfork.org/zh-CN/scripts/468911-%E7%BB%9F%E8%AE%A1%E9%80%89%E4%B8%AD%E5%AD%97%E7%AC%A6%E6%95%B0%E9%87%8F-powered-by-gpt-character-count-tracker
// @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);
})();