您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Greasy Fork is available in English.
自动给页面中的英文和中文中间添加空格,文本中如果包含 A 标签,则在 A 标签的前后也添加空格
// ==UserScript== // @name 自动给页面中的英文和中文中间添加空格 // @namespace http://tampermonkey.net/ // @version 0.3 // @description 自动给页面中的英文和中文中间添加空格,文本中如果包含 A 标签,则在 A 标签的前后也添加空格 // @author mxlg2003 // @match *://*/* // @grant none // @license MIT // ==/UserScript== (function() { 'use strict'; // Function to add space around A tags and between English and Chinese characters function addSpaces(node) { if (node.nodeType === Node.ELEMENT_NODE) { // Process element nodes if (node.nodeName !== 'SCRIPT' && node.nodeName !== 'STYLE' && node.nodeName !== 'NOSCRIPT') { // Add node around A tags if (node.querySelector('a')) { // Replace the content of the node with spaces around A tags node.innerHTML = node.innerHTML.replace(/(<a[^>]*>)(.*?)(<\/a>)/g, ' $1$2$3 '); } for (let child = node.firstChild; child; child = child.nextSibling) { addSpaces(child); } } } else if (node.nodeType === Node.TEXT_NODE) { // Process text nodes let text = node.nodeValue; // Add spaces between English and Chinese characters text = text.replace(/([\u4e00-\u9fa5])([A-Za-z0-9])/g, '$1 $2'); text = text.replace(/([A-Za-z0-9])([\u4e00-\u9fa5])/g, '$1 $2'); node.nodeValue = text; } } // Initial run addSpaces(document.body); })();