Punctuation color

https://www.reddit.com/r/userscripts/comments/gnoji7/request_punctuation_color/

이 스크립트를 설치하려면 Tampermonkey, Greasemonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

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

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Userscripts와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 유저 스크립트 관리자 확장 프로그램이 필요합니다.

(이미 유저 스크립트 관리자가 설치되어 있습니다. 설치를 진행합니다!)

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

(이미 유저 스타일 관리자가 설치되어 있습니다. 설치를 진행합니다!)

// ==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'>&mdash;</span>");

  modifiedText = modifiedText.replace(/―/gi, "<span class='highlightMdash'>&horbar;</span>");
  modifiedText = modifiedText.replace(/,/gi, "<span class='highlightComa'>,</span>");
  modifiedText = modifiedText.replace(/‒/gi, "<span class='highlightNdash'>&ndash;</span>");
  modifiedText = modifiedText.replace(/–/gi, "<span class='highlightNdash'>&#8210;</span>");
  modifiedText = modifiedText.replace(/“/gi, "<span class='highlightDoubleQuotes'>“</span>");
  modifiedText = modifiedText.replace(/”/gi, "<span class='highlightDoubleQuotes'>”</span>");

  $('body').html(modifiedText);

})();