CF problemset to contest

Display CF problems in the contest field instead of problemset

As of 2019-10-17. See the latest version.

  1. // ==UserScript==
  2. // @name CF problemset to contest
  3. // @namespace http://tampermonkey.net/
  4. // @version 2.1
  5. // @description Display CF problems in the contest field instead of problemset
  6. // @author ouuan
  7. // @match *://codeforces.com/problemset*
  8. // @match *://codeforc.es/problemset*
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14. var matches = window.location.href.match(/\/problemset\/problem\/([1-9][0-9]*)\/([A-Z][1-9]?)/);
  15. if (matches) window.location.replace("https://codeforces.com/contest/" + matches[1] + "/problem/" + matches[2]);
  16.  
  17. var links = document.querySelectorAll('a');
  18.  
  19. for (var link of links) {
  20. matches = link.href.match(/\/problemset\/problem\/([1-9][0-9]*)\/([A-Z][1-9]?)/);
  21. if (matches) link.href = ("https://codeforces.com/contest/" + matches[1] + "/problem/" + matches[2]);
  22. }
  23. })();