Greasy Fork is available in English.

mod noticer

modを取る必要がありそうだったら教えてくれます!嬉しいね(うれしいので) ソースコード内で通知位置の設定が可能です!

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

  1. // ==UserScript==
  2. // @name mod noticer
  3. // @namespace http://atcoder.jp/
  4. // @version 2.2
  5. // @description modを取る必要がありそうだったら教えてくれます!嬉しいね(うれしいので) ソースコード内で通知位置の設定が可能です!
  6. // @author Ll_e_ki
  7. // @license MIT
  8. // @match https://atcoder.jp/contests/*/tasks/*
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. /*
  13. LICENCE : MIT
  14.  
  15. Copyright © 2023 Ll_e_ki
  16.  
  17. https://opensource.org/license/mit/
  18. */
  19.  
  20. (function() {
  21. 'use strict';
  22.  
  23. // Your code here...
  24.  
  25. const NOTICE_POSITION = {
  26. IN_SUBMIT : true, // 提出ボタン内
  27. ABOVE_SUBMIT : false, // 提出ボタンの上
  28. DIALOG : false // 提出時、提出コードでmodを取り忘れている場合ダイアログ表示
  29. // 複数選択も可能です
  30. }
  31. const MODMARK = [ // ダイアログ表示を使用する場合、modを取っているかの確認用文言を予め入力してください
  32. "%"
  33. ]
  34. const MOD_LIST = ["割ったあまり", "割った余り", "答えは非常に大きく", "mod"]
  35.  
  36. function inWord(root_element, word_list) {
  37. let elem_stack = [root_element]
  38.  
  39. while (elem_stack.length > 0) {
  40. var element = elem_stack.pop()
  41. for (var i = 0; i < word_list.length; i++) {
  42. if (element.textContent.match(word_list[i])) {
  43. return true
  44. }
  45. }
  46. if (element.children.length > 0) {
  47. var children = element.children
  48. for (var i = 0; i < children.length; i++) {
  49. elem_stack.push(children[i])
  50. }
  51. }
  52. }
  53.  
  54. return false
  55. }
  56.  
  57. let task_element = document.getElementById("task-statement")
  58. let global_needmod = inWord(task_element, MOD_LIST)
  59. if (global_needmod) {
  60. if (NOTICE_POSITION.IN_SUBMIT) {
  61. document.getElementById("submit").appendChild(document.createElement("br"))
  62. document.getElementById("submit").appendChild(document.createTextNode("※ modは取りましたか?"))
  63. }
  64. if (NOTICE_POSITION.ABOVE_SUBMIT) {
  65. var append_elem = document.createElement("b")
  66. append_elem.textContent = "※ modは取りましたか?"
  67. document.getElementById("sourceCode").appendChild(append_elem)
  68. }
  69. }
  70.  
  71. document.getElementById("submit").addEventListener("click", (event) => {
  72. if (NOTICE_POSITION.DIALOG && global_needmod) {
  73. let code_element = document.getElementById("sourceCode")
  74. if (inWord(code_element, MODMARK) == false && confirm("modを取っていない可能性があります。提出しますか?") == false) {
  75. event.preventDefault()
  76. }
  77. }
  78. })
  79. })()