CF problemset to contest

Display CF problems in the contest field instead of problemset

  1. // ==UserScript==
  2. // @name CF problemset to contest
  3. // @namespace http://tampermonkey.net/
  4. // @version 2.2
  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. // @run-at document-start
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15. var matches = window.location.href.match(/\/problemset\/problem\/([1-9][0-9]*)\/([A-Z][1-9]?)/);
  16. if (matches) window.location.replace("https://codeforces.com/contest/" + matches[1] + "/problem/" + matches[2]);
  17.  
  18. var links = document.querySelectorAll('a');
  19.  
  20. for (var link of links) {
  21. matches = link.href.match(/\/problemset\/problem\/([1-9][0-9]*)\/([A-Z][1-9]?)/);
  22. if (matches) link.href = ("https://codeforces.com/contest/" + matches[1] + "/problem/" + matches[2]);
  23. }
  24. })();