AtCoder Hide Editorial

hide editorial

  1. // ==UserScript==
  2. // @name AtCoder Hide Editorial
  3. // @namespace AtCoder
  4. // @version 0.5
  5. // @description hide editorial
  6. // @author harurun
  7. // @match https://atcoder.jp/contests/*/tasks/*/editorial*
  8. // @match https://atcoder.jp/contests/*/editorial*
  9. // @match https://atcoder.jp/contests/*/tasks/*
  10. // @license MIT
  11. // @grant none
  12. // ==/UserScript==
  13.  
  14. function usernames() {
  15. var usr=document.getElementsByClassName("username")
  16. for(var i=0;i<usr.length;i++){
  17. usr[i].removeAttribute("href")
  18. usr[i].textContent="hide editorial"
  19. }
  20. }
  21.  
  22. function editional() {
  23. 'use strict';
  24. var alist=document.getElementsByTagName("a")
  25. for(var i=0;i<alist.length;i++){
  26. var target=alist[i]
  27. var url=target.href
  28. if(target.textContent==''||url.match('https://www.addtoany.com/.*')||url.match('http://www.timeanddate.com/worldclock/.*')||url.match('https://www.timeanddate.com/worldclock/.*')){
  29. continue;
  30. }
  31. if(url.match('https://youtu.be/.*')||url.match('https://atcoder.jp/contests/.*/editorial/.*')||!(url.match('https://atcoder.jp/.*'))){
  32. //target.href="javascript:void(0)"
  33. target.removeAttribute("href")
  34. target.textContent="hide editorial"
  35. }
  36. }
  37. usernames()
  38. }
  39.  
  40. function problem() {
  41. var alist=document.getElementsByTagName("a")
  42. for(var i=0;i<alist.length;i++){
  43. var target=alist[i]
  44. var url=target.href
  45. if(url.match('https://atcoder.jp/contests/.*/tasks/.*/editorial')||url.match('https://atcoder.jp/contests/*/tasks/*/editorial')){
  46. target.removeAttribute("href")
  47. target.textContent="hide editorial"
  48. }
  49. }
  50. usernames()
  51. }
  52.  
  53. function main() {
  54. var url=location.href
  55. if(url.match('https://atcoder.jp/contests/.*/tasks/.*/editorial')){
  56. //console.log("hide editorial(editorial)")
  57. editional()
  58. }else if(url.match('https://atcoder.jp/contests/.*/tasks/.*')||url.match('https://atcoder.jp/contests/.*/tasks/.*?lang=en')){
  59. //console.log('hide editorial(problem)')
  60. problem()
  61. }else if(url.match('https://atcoder.jp/contests/.*/editorial')||url.match('https://atcoder.jp/contests/.*/tasks/.*/editorial')||url.match('https://atcoder.jp/contests/.*/editorial?lang=en')||url.match('https://atcoder.jp/contests/.*/tasks/.*/editorial')){
  62. //console.log('hide editorial(editorial)')
  63. editional()
  64. }
  65. }
  66.  
  67. main()