AtCoder Hide Editorial

hide editorial

Versione datata 16/04/2021. Vedi la nuova versione l'ultima versione.

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==UserScript==
// @name         AtCoder Hide Editorial
// @namespace    AtCoder
// @version      0.3
// @description  hide editorial
// @author       harurun
// @match        https://atcoder.jp/contests/*/tasks/*/editorial
// @match        https://atcoder.jp/contests/*/tasks/*/editorial?editorialLang=en
// @match        https://atcoder.jp/contests/*/editorial
// @match        https://atcoder.jp/contests/*/editorial?editorialLang=en
// @match        https://atcoder.jp/contests/*/tasks/*
// @match        https://atcoder.jp/contests/*/tasks/*?lang=ja
// @grant        none
// ==/UserScript==

function editional() {
  'use strict';
  var alist=document.getElementsByTagName("a")
  for(var i=0;i<alist.length;i++){
    var target=alist[i]
    var url=target.href
    if(target.textContent==''||url.match('https://www.addtoany.com/.*')||url.match('http://www.timeanddate.com/worldclock/.*')||url.match('https://www.timeanddate.com/worldclock/.*')){
      continue
    }
    if(url.match('https://youtu.be/.*')||url.match('https://atcoder.jp/contests/.*/editorial/.*')||!(url.match('https://atcoder.jp/.*'))){
      //target.href="javascript:void(0)"
      target.removeAttribute("href")
      target.textContent="hide editorial"
    }
  }
}

function problem() {
  var alist=document.getElementsByTagName("a")
  for(var i=0;i<alist.length;i++){
    var target=alist[i]
    var url=target.href
    if(url.match('https://atcoder.jp/contests/.*/tasks/.*/editorial')||url.match('https://atcoder.jp/contests/*/tasks/*/editorial')){
      target.removeAttribute("href")
      target.textContent="hide editorial"
    }
  }
}

function main() {
  var url=location.href
  if(url.match('https://atcoder.jp/contests/.*/tasks/.*/editorial')){
    //console.log("hide editorial(editorial)")
    editional()
  }else if(url.match('https://atcoder.jp/contests/.*/tasks/.*')||url.match('https://atcoder.jp/contests/.*/tasks/.*?lang=en')){
    //console.log('hide editorial(problem)')
    problem()
  }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')){
    //console.log('hide editorial(editorial)')
    editional()
  }
}

main()