atcoder-keyboard-shortcuts

atcoder keyboard shortcuts

当前为 2020-03-09 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name atcoder-keyboard-shortcuts
  3. // @namespace https://halmk.github.io/
  4. // @version 0.1
  5. // @description atcoder keyboard shortcuts
  6. // @author springroll
  7. // @match https://atcoder.jp/contests/*/tasks/*
  8. // @grant none
  9. // @require https://unpkg.com/hotkeys-js/dist/hotkeys.min.js
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14. var copySample = function(index) {
  15. window.getSelection().removeAllRanges();
  16. try {
  17. var range = document.createRange();
  18. range.selectNode($('#pre-sample'+(2*(index-1))).get(0));
  19. window.getSelection().addRange(range);
  20. document.execCommand('copy');
  21. } catch (err) {
  22. console.log(err);
  23. }
  24. alert("Copied Sample" + index + ".");
  25. window.getSelection().removeAllRanges();
  26. }
  27. hotkeys('shift+1,shift+2,shift+3,shift+4,shift+5', function (event, handler){
  28. switch (handler.key) {
  29. case 'shift+1':
  30. copySample(1);
  31. break;
  32. case 'shift+2':
  33. copySample(2);
  34. break;
  35. case 'shift+3':
  36. copySample(3);
  37. break;
  38. case 'shift+4':
  39. copySample(4);
  40. break;
  41. case 'shift+5':
  42. copySample(5);
  43. break;
  44. default: alert(event);
  45. }
  46. });
  47.  
  48. })();

QingJ © 2025

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