添加洛谷链接,以及status快捷导航栏 codeforces add Luogu link, and status shortcut navigation bar

Introduces a button which takes you to the friends standings directly

当前为 2023-07-05 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @license MIT
  3. // @name 添加洛谷链接,以及status快捷导航栏 codeforces add Luogu link, and status shortcut navigation bar
  4. // @namespace http://tampermonkey.net/
  5. // @version 0.1
  6. // @description Introduces a button which takes you to the friends standings directly
  7. // @author funcdfs
  8. // @match https://codeforces.com/*/problem/*
  9. // @icon https://www.google.com/s2/favicons?sz=64&domain=codeforces.com
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13. // friends-status-button
  14. (function () {
  15. 'use strict';
  16. let url = window.location;
  17. let contestId = url.toString().split("/").filter((x) => {
  18. if (typeof x !== 'string') { return; }
  19. const num = Number(x);
  20. if (Number.isInteger(num)) { return num; }
  21. })[0];
  22. let s = url.toString().split("/");
  23. let id = s[s.length - 1];
  24. let friendBtn = document.createElement('li');
  25.  
  26. friendBtn.innerHTML = `<a href="https://codeforces.com/contest/${contestId}/status/${id}?friends=on" target="_blank">Friends Status</a>`;
  27. friendBtn.classList.add('friendBtn')
  28. document.querySelector(".second-level-menu-list").appendChild(friendBtn);
  29. })();
  30.  
  31. // jump to luogu.com
  32. const pathname = location.pathname
  33.  
  34. if (/\/problemset\/problem\/(\d*)\/([A-Z][1-9]?)$/.test(pathname)) {
  35. location.href = `/contest/${RegExp.$1}/problem/${RegExp.$2}`;
  36. }
  37. else if (/\/contest\/(\d*)\/problem\/([A-Z][1-9]?)$/.test(pathname)) {
  38. let x = $('.header>.title'), y = x.html();
  39. x.html(`${RegExp.$1}<a href="https://www.luogu.com.cn/problem/CF${RegExp.$1 + RegExp.$2}" target="_blank">${y}</a>`);
  40. }
  41. if (0) {
  42. var stateObject = {};
  43. var title = "Wow Title";
  44. var newUrl = "/my/awesome/url";
  45. history.pushState(stateObject, title, newUrl);
  46. }
  47.  
  48. //