Greasy Fork is available in English.

AtCoderCharacterColorizer

Colorize kanji meaning color in statements

2021-07-25 يوللانغان نەشرى. ئەڭ يېڭى نەشرىنى كۆرۈش.

  1. // ==UserScript==
  2. // @name AtCoderCharacterColorizer
  3. // @namespace https://satanic0258.github.io/
  4. // @version 0.1.1
  5. // @description Colorize kanji meaning color in statements
  6. // @author satanic0258
  7. // @match https://atcoder.jp/contests/*/tasks/*
  8. // @grant none
  9. // ==/UserScript==
  10. /*!
  11. * AtCoderCharacterColorizer v0.1.1
  12. *
  13. * Copyright (c) 2021 satanic0258
  14. *
  15. * This software is released under the MIT license.
  16. * see https://opensource.org/licenses/MIT
  17. */
  18. (function() {
  19. 'use strict';
  20.  
  21. const statement = document.getElementById("task-statement");
  22. function background(c, r, g, b, a) {
  23. return "<span style='background-color:rgba("+r+","+g+","+b+","+a+");'>"+c+"</span>";
  24. }
  25. function white(c) {
  26. return "<span style='color:#fff;text-shadow:1px 0px 1px #000,0px 1px 1px #000,-1px 0px 1px #000,0px -1px 1px #000;'>"+c+"</span>";
  27. }
  28. statement.innerHTML = statement.innerHTML
  29. .replace(/黒/g, background('黒', 0, 0, 0, 0.3))
  30. .replace(/ブラック/g, background('ブラック', 0, 0, 0, 0.3))
  31. .replace(/青([^木])/g, background('青', 0, 0, 255, 0.3) + '$1')
  32. .replace(/緑/g, background('緑', 0, 255, 0, 0.3))
  33. .replace(/水/g, background('水', 0, 255, 255, 0.3))
  34. .replace(/藍/g, background('藍', 15, 84, 116, 0.3))
  35. .replace(/灰/g, background('灰', 127, 127, 127, 0.3))
  36. .replace(/銀/g, background('銀', 127, 127, 127, 0.3))
  37. .replace(/紫/g, background('紫', 162, 96, 191, 0.4))
  38. .replace(/茶/g, background('茶', 184, 115, 51, 0.4))
  39. .replace(/銅/g, background('銅', 184, 115, 51, 0.4))
  40. .replace(/桃/g, background('桃', 240, 145, 153, 0.4))
  41. .replace(/ピンク/g, background('ピンク', 240, 145, 153, 0.4))
  42. .replace(/赤/g, background('赤', 255, 0, 0, 0.3))
  43. .replace(/橙/g, background('橙', 255, 127, 0, 0.3))
  44. .replace(/オレンジ/g, background('オレンジ', 255, 127, 0, 0.3))
  45. .replace(/黄/g, background('黄', 255, 255, 0, 0.5))
  46. .replace(/金/g, background('金', 255, 255, 0, 0.5))
  47. .replace(/白/g, white('白'))
  48. .replace(/ホワイト/g, white('ホワイト'));
  49. })();