BZBZ

https://github.com/billchenchina/BZBZ

  1. // ==UserScript==
  2. // @name BZBZ
  3. // @version 1.0.0
  4. // @description https://github.com/billchenchina/BZBZ
  5. // @author Originally by billchenchina, Edited by ZZYSonny
  6. // @match *://www.lydsy.com/JudgeOnline/problem.php?id=*
  7. // @connect ruanx.pw
  8. // @grant GM_xmlhttpRequest
  9. // @namespace https://greasyfork.org/users/169007
  10. // ==/UserScript==
  11.  
  12. ojLink = function(pid) {
  13. return pid
  14. .replace(/^Luogu([0-9]+)$/, "https://www.luogu.org/problemnew/show/P$1")
  15. .replace(/^Loj([0-9]+)$/, "https://loj.ac/problem/$1")
  16. .replace(/^Codevs([0-9]+)$/, "http://codevs.cn/problem/$1/")
  17. .replace(/^Cogs([0-9]+)$/,"http://cogs.pro:8080/cogs/problem/problem.php?pid=$1")
  18. .replace(/^Vijos([0-9]+)$/, "https://vijos.org/p/$1");
  19. };
  20.  
  21. appendLink = function(url, title) {
  22. const ele = document.getElementsByTagName("h2");
  23. var link = document.createElement("a");
  24. link.href = url;
  25. link.text = title + "\n";
  26. ele[0].appendChild(link);
  27. };
  28.  
  29. function add_link() {
  30. var problem_id_q0dsah6q4v2ex6oh4 = location.href.split("=")[1];
  31.  
  32. GM_xmlhttpRequest({
  33. method: "GET",
  34. url: "https://ruanx.pw/bzojch/result.json",
  35. onload: function(res) {
  36. var text = res.responseText;
  37. var result = JSON.parse(text);
  38.  
  39. for (let i in result) {
  40. if (result[i][0] == problem_id_q0dsah6q4v2ex6oh4) {
  41. console.log(result[i]);
  42.  
  43. var res1 = result[i][4];
  44. var res2 = result[i][6];
  45.  
  46. console.log(ojLink(res1));
  47. console.log(ojLink(res2));
  48. const ele = document.getElementsByTagName("h2");
  49. ele[0].innerText += "\n其他OJ链接: ";
  50. appendLink(ojLink(res1), res1);
  51. appendLink(ojLink(res2), res2);
  52. }
  53. }
  54. }
  55. });
  56. }
  57. add_link();