Send to VJudge

Get code submitted to other task sites and send it to VJudge

目前为 2023-08-13 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Send to VJudge
  3. // @namespace -
  4. // @version 5
  5. // @description Get code submitted to other task sites and send it to VJudge
  6. // @author Plantt
  7. // @match https://open.kattis.com/problems/*
  8. // @match https://open.kattis.com/contests/*/problems/*
  9. // @match https://cses.fi/problemset/*/*
  10. // @match https://oj.uz/problem/*
  11. // @match https://www.eolymp.com/*/problems/*
  12. // @match https://codeforces.com/*/problem/*
  13. // @match https://onlinejudge.org/external/*/*.pdf
  14. // @icon https://www.google.com/s2/favicons?sz=64&domain=vjudge.net
  15. // @grant none
  16. // @license Unlicense
  17. // ==/UserScript==
  18.  
  19. window.addEventListener("load", function() {
  20. var btn;
  21. if (document.URL.includes("https://open.kattis.com")) {
  22. btn = document.createElement("a");
  23. btn.innerText = "Send to VJudge";
  24. btn.className = "tab-nav-item tab-nav-js";
  25. btn.onclick = () => {
  26. window.open("https://vjudge.net/problem/kattis-" + document.URL.substr(document.URL.lastIndexOf("/") + 1), "_blank");
  27. };
  28. document.querySelector("#edit-and-submit-tab > div > div.strip-item-plain > nav").appendChild(btn);
  29. }
  30. else if (document.URL.includes("https://cses.fi")) {
  31. btn = document.createElement("li");
  32. btn.innerHTML = `<a href="//vjudge.net/problem/cses-${document.URL.substr(document.URL.lastIndexOf("/") + 1)}" target="_blank">Send to VJudge</a>`;
  33. document.querySelector("body > div.skeleton > div.navigation > div.title-block > ul").appendChild(btn);
  34. }
  35. else if (document.URL.includes("https://oj.uz")) {
  36. btn = document.createElement("li");
  37. btn.innerHTML = `<a href="https://vjudge.net/problem/OJUZ-${document.URL.substr(document.URL.lastIndexOf("/") + 1)}" target="_blank">Send to VJudge</a>`;
  38. document.querySelector("#content > div > div > div.col-lg-9 > ul").appendChild(btn);
  39. }
  40. else if (document.URL.includes("https://www.eolymp.com")) {
  41. btn = document.createElement("a");
  42. btn.href = `//vjudge.net/problem/EOlymp-${document.URL.substr(document.URL.lastIndexOf("/") + 1)}`;
  43. btn.className = "eo-tabs __tab";
  44. btn.target = "_blank";
  45. btn.innerText = "Send to VJudge";
  46. document.querySelector("body > main > div.eo-container > div.eo-toolbar.eo-toolbar_white > nav").appendChild(btn);
  47. }
  48. else if (document.URL.includes("https://codeforces.com")) {
  49. btn = document.createElement("li");
  50. let match = document.URL.match(/https:\/\/codeforces\.com\/.+?\/problem\/(\d+?)\/(\w+?)/);
  51. btn.innerHTML = `<a href="//vjudge.net/problem/CodeForces-${match[1]}${match[2]}" target="_blank">Send to VJudge</a>`;
  52. document.querySelector("#pageContent > div.second-level-menu > ul.second-level-menu-list").appendChild(btn);
  53. }
  54. else if (document.URL.includes("https://onlinejudge.org")) {
  55. btn = document.createElement("a");
  56. btn.href = `//vjudge.net/problem/UVA-${document.URL.substr(document.URL.lastIndexOf("/") + 1)}`;
  57. btn.href = btn.href.substr(0, btn.href.length - 4);
  58. btn.innerHTML = "<button>Send to VJudge</button>";
  59. btn.style.position = "fixed";
  60. btn.style.top = btn.style.left = 0;
  61. document.body.appendChild(btn);
  62. }
  63. console.log("Send to VJudge button:", btn);
  64. });