您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
https://www.reddit.com/r/userscripts/comments/gnoji7/request_punctuation_color/
- // ==UserScript==
- // @name Punctuation color
- // @description https://www.reddit.com/r/userscripts/comments/gnoji7/request_punctuation_color/
- // @author Livadas
- // @include *
- // @require http://code.jquery.com/jquery-latest.js
- // @run-at document-idle
- // @version 2020-05-27
- // @namespace https://greasyfork.org/users/237051
- // ==/UserScript==
- (function() {
- function addGlobalStyle(css) {
- var head, style;
- head = document.getElementsByTagName('head')[0];
- if (!head) { return; }
- style = document.createElement('style');
- style.type = 'text/css';
- style.innerHTML = css;
- head.appendChild(style);
- }
- addGlobalStyle(".highlightComa {color:red!important; background-color:white;}");
- addGlobalStyle(".highlightMdash {color:blue!important; background-color:white;}");
- addGlobalStyle(".highlightNdash {color:blue!important; background-color:white;}");
- addGlobalStyle(".highlightDoubleQuotes {color:green!important; background-color:white;}");
- var docText = $('body')[0].innerHTML;
- var modifiedText = docText.replace(/—/gi, "<span class='highlightMdash'>—</span>");
- modifiedText = modifiedText.replace(/―/gi, "<span class='highlightMdash'>―</span>");
- modifiedText = modifiedText.replace(/,/gi, "<span class='highlightComa'>,</span>");
- modifiedText = modifiedText.replace(/‒/gi, "<span class='highlightNdash'>–</span>");
- modifiedText = modifiedText.replace(/–/gi, "<span class='highlightNdash'>‒</span>");
- modifiedText = modifiedText.replace(/“/gi, "<span class='highlightDoubleQuotes'>“</span>");
- modifiedText = modifiedText.replace(/”/gi, "<span class='highlightDoubleQuotes'>”</span>");
- $('body').html(modifiedText);
- })();