您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
仿真Burning Vocabulary,没有翻译功能,仅限于在经济学人网站上对单词进行标注
当前为
// ==UserScript== // @name Burning Vocabulary类似版 // @namespace http://tampermonkey.net/ // @version 1.1 // @description 仿真Burning Vocabulary,没有翻译功能,仅限于在经济学人网站上对单词进行标注 // @author TCH // @match *://www.economist.com // @match *://*economist.com/* // @grant GM_setValue // @grant GM_deleteValue // @grant GM_listValues // @license tangchuanhui // ==/UserScript== (function() { function makecolor(searchVal, nColor) { var oDiv = document.getElementsByTagName("body")[0]; var sText = oDiv.innerHTML; searchVal = " " + searchVal; var sKey = "<span name='addSpan' style='color:" + nColor + "';>" + searchVal + "</span>"; var num = -1; var rStr = new RegExp(searchVal, "g"); var rHtml = new RegExp("\<.*?\>", "ig"); //匹配html元素 var aHtml = sText.match(rHtml); //存放html元素的数组 sText = sText.replace(rHtml, '{~}'); //替换html标签 sText = sText.replace(rStr, sKey); //替换key sText = sText.replace(/{~}/g, function() { //恢复html标签 num++; return aHtml[num]; }); oDiv.innerHTML = sText; } let list_value = GM_listValues(); for (var i = 0; i < list_value.length; i++) { makecolor(list_value[i], "red"); } var selectionFirst = null; var selectionSecond = null; document.addEventListener("selectionchange", () => { selectionFirst = selectionSecond; selectionSecond = document.getSelection() .toString(); }); let div = document.createElement("div"); div.style = "position:fixed; bottom:20px; left: 0; margin: auto; right: 0;text-align:center;" div.innerHTML = '<span id="biaozhubiaozhu"style="width:150rpx;margin:15px;background-color: red;font-size: 30px;border-color: red;border-radius: 5px;" >标注</span><span id="quxiaobiaozhu" style="width:150rpx;margin:15px;background-color: black;font-size: 30px;color: white;border-radius: 5px;">取消</span>'; document.onclick = function(event) { if (event.target.id == "biaozhubiaozhu") { selectionFirst = selectionSecond; //在有些浏览器,需要把这句去除 if (selectionFirst !== null && selectionFirst !== void 0 && selectionFirst.toString()) { GM_setValue(selectionFirst, selectionFirst); makecolor(selectionFirst, "red"); } } else if (event.target.id == "quxiaobiaozhu") { selectionFirst = selectionSecond; //在有些浏览器,需要把这句去除 if (selectionFirst !== null && selectionFirst !== void 0 && selectionFirst.toString()) { GM_deleteValue(selectionFirst) makecolor(selectionFirst, "black"); } } }; document.body.append(div); })();
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址