Luogu Problem Jumper

双击题号,自动跳转

目前为 2019-08-19 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name Luogu Problem Jumper
  3. // @version 1.3
  4. // @description 双击题号,自动跳转
  5. // @author Anguei, ouuan
  6. // @match https://www.luogu.org/*
  7. // @match https://*.blog.luogu.org/*
  8. // @grant none
  9. // @namespace Anguei
  10. // ==/UserScript==
  11.  
  12. function jump() {
  13. var selection = window.getSelection();
  14. var selected = selection.toString();
  15. selected = selected.replace(' ', '').toUpperCase();
  16.  
  17. if (isProblemId(selected)) {
  18. var url = window.location.href;
  19. window.open(
  20. url.match(/message/) != undefined ?
  21. 'https://' + url.match(/uid=([0-9]+)/)[1] +
  22. '.blog.luogu.org/solution-' + selected :
  23. 'https://www.luogu.org/problem/' + selected);
  24. selection.removeAllRanges();
  25. }
  26.  
  27. function isProblemId(text) {
  28. if (text.match(/AT[0-9]{1,4}/) == text) return true;
  29. if (text.match(/CF[0-9]{1,4}[A-Z][0-9]{0,1}/) == text) return true;
  30. if (text.match(/SP[0-9]{1,5}/) == text) return true;
  31. if (text.match(/P[0-9]{4}/) == text) return true;
  32. if (text.match(/UVA[0-9]{1,5}/) == text) return true;
  33. if (text.match(/U[0-9]{1,6}/) == text) return true;
  34. if (text.match(/T[0-9]{1,6}/) == text) return true;
  35. return false;
  36. }
  37. }
  38.  
  39. function checkUA() {
  40. var ua = navigator.userAgent;
  41. return ua.indexOf('Android') > -1;
  42. }
  43.  
  44. if ((window.screen.width / window.screen.height < 0.6) || checkUA) {
  45. document.addEventListener('selectionchange', jump);
  46. } else {
  47. document.ondblclick = jump;
  48. }

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址