您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
try to take over the world!
// ==UserScript== // @name 蓝湖-复制单位转为rpx // @namespace http://tampermonkey.net/ // @version 0.3 // @description try to take over the world! // @author villiam // @match https://lanhuapp.com/web/ // @icon https://www.google.com/s2/favicons?sz=64&domain=lanhuapp.com // @grant none // ==/UserScript== (function () { "use strict"; document.addEventListener("copy", function (e) { let clipboardData = e.clipboardData || window.clipboardData; // 如果 未复制或者未剪切,直接 return if (!clipboardData) return; // Selection 对象 表示用户选择的文本范围或光标的当前位置。 // 声明一个变量接收 -- 用户输入的剪切或者复制的文本转化为字符串 var text = window.getSelection().toString(); if (text) { // 如果文本存在,首先取消默认行为 e.preventDefault(); // 通过调用 clipboardData 对象的 setData(format,data) 方法,设置相关文本 //替换单位为rpx text = text.replace(/px/g, "rpx"); if (text.indexOf("font-family: Source Han Sans CN;") > -1) { text = text.replace("font-family: Source Han Sans CN;", "") } clipboardData.setData("text/plain", text); } }); })();