洛谷快捷键LuoguShortcutKeys

提供便捷的洛谷快捷键

目前为 2021-06-21 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name 洛谷快捷键LuoguShortcutKeys
  3. // @namespace https://github.com/Aksadfjh/LuoguShortcutKeys
  4. // @version 0.5
  5. // @description 提供便捷的洛谷快捷键
  6. // @author Aksadfjh
  7. // @match https://www.luogu.com.cn/*
  8. // @match http://www.luogu.com.cn/*
  9. // @match https://www.luogu.org/*
  10. // @match http://www.luogu.org/*
  11. // @match https://blog.luogu.com.cn/*
  12. // @match http://blog.luogu.com.cn/*
  13. // @match https://blog.luogu.org/*
  14. // @match http://blog.luogu.org/*
  15. // @icon https://www.google.com/s2/favicons?domain=luogu.com.cn
  16. // @grant unsafeWindow
  17. // @require https://code.jquery.com/jquery-2.1.1.min.js
  18. // ==/UserScript==
  19.  
  20. (function () {
  21.  
  22. /////////////// 内测版 ///////////////
  23. // 提供最基本的快捷键Ctrl+Enter发送犇犇
  24. // 其他功能,敬请期待!
  25. ////////////// END ////////////////
  26.  
  27. /************* 更新日志 ************/
  28. // v0.1: 基础版本,发布最基础功能;
  29. // v0.5: 增加Ctrl+Enter发送帖子回复;全新键盘监听方式;全新console;
  30. /**********************************/
  31.  
  32. console.clear();
  33. console.log('%c[Luogu Shortcut Keys]加载成功,欢迎使用!', 'background-image:-webkit-gradient( linear, left top, right top, color-stop(0, #f22), color-stop(0.15, #f2f), color-stop(0.3, #22f), color-stop(0.45, #2ff), color-stop(0.6, #2f2),color-stop(0.75, #2f2), color-stop(0.9, #ff2), color-stop(1, #f22) );color:transparent;-webkit-background-clip: text;font-size:2em;');
  34. console.log("[Luogu Shortcut Keys]作者:Aksadfjh, 当前版本:0.0.5, 项目地址:https://github.com/Aksadfjh/LuoguShortcutKeys, 油猴:https://gf.qytechs.cn/zh-CN/scripts/428234");
  35. // console.log('%c[Luogu Shortcut Keys]加载成功,欢迎使用!', 'font-size:20px')
  36. // console.log("[Luogu Shortcut Keys]加载成功, 版本:0.5, 作者:Trotyl, 项目地址:https://github.com/Aksadfjh/LuoguShortcutKeys");
  37.  
  38. var urlpath = window.location.pathname, url = window.location.href;
  39.  
  40. function btnClick(btnid) {
  41. $("#" + btnid).click();
  42. }
  43.  
  44. function hfiClick(herfid) {
  45. document.getElementById(herfid).click();
  46. }
  47.  
  48. function hfnClick(herfname) {
  49. document.querySelector('[name=' + herfname + ']').click();
  50. }
  51.  
  52. function msgConfirm(tip) {
  53. if (confirm(tip) == true) {
  54. return true;
  55. } else {
  56. return false;
  57. }
  58. }
  59.  
  60. function tipShow(tip, type) {
  61. var $tip = $('#tip');
  62. if ($tip.length == 0) {
  63. $tip = $('<span id="tip" style="position:fixed; top:50px; left: 50%; z-index:9999; height: 35px; padding: 0 20px; line-height: 35px; background-color: white; color: red; border: 5px; opacity: 10%"></span>');
  64. $('body').append($tip);
  65. }
  66. $tip.stop(true).prop('class', 'alert alert-' + type).text(tip).css('margin-left', -$tip.outerWidth() / 2).fadeIn(250).delay(500).fadeOut(250);
  67. }
  68.  
  69. function msgShow(msg) {
  70. tipShow(msg, 'info');
  71. }
  72.  
  73. // var keybuf = {};
  74.  
  75. function strIc(stra, strb) {
  76. if (stra.indexOf(strb) != -1) return true;
  77. return false;
  78. }
  79.  
  80. function btnSendDsb() {
  81. if (strIc(urlpath, "discuss/show/")) {
  82. console.log(urlpath, strIc(urlpath, "discuss/show/"));
  83. hfiClick("submit-reply");
  84. }
  85. if (url == "https://www.luogu.com.cn/") {
  86. btnClick("feed-submit");
  87. console.log(url);
  88. }
  89. }
  90.  
  91. function btnDeleteDsb() {
  92. if (strIc(urlpath, "discuss/show/")) {
  93. console.log(urlpath, strIc(urlpath, "discuss/show/"));
  94. hfnClick("delete-reply");
  95. }
  96. if (url == "https://www.luogu.com.cn/") {
  97. btnClick("feed-delete");
  98. console.log(url);
  99. }
  100. }
  101.  
  102. function keyLis(sk) {
  103. var keys = {};
  104.  
  105. $(document.body).keydown(function (event) {
  106. // save status of the button 'pressed' == 'true'
  107. for (i in sk) {
  108. if (event.keyCode == sk[i]) {
  109. keys[sk[i]] = true;
  110. }
  111. }
  112. var f = true;
  113. for (i in sk) {
  114. if (!keys[sk[i]]) {
  115. f = false;
  116. }
  117. }
  118. if (f) {
  119. btnSendDsb();
  120. msgShow("发送成功");
  121. return true;
  122. }
  123. });
  124.  
  125. $(document.body).keyup(function (event) {
  126. // reset status of the button 'released' == 'false'
  127. for (i in sk) {
  128. if (event.keyCode == sk[i]) {
  129. keys[sk[i]] = false;
  130. }
  131. }
  132. });
  133. }
  134.  
  135. function twoKeyLis(a, b) {
  136. var keys = {};
  137.  
  138. $(document.body).keydown(function (event) {
  139. // save status of the button 'pressed' == 'true'
  140. if (event.keyCode == a) {
  141. keys[a] = true;
  142. } else if (event.keyCode == b) {
  143. keys[b] = true;
  144. }
  145. if (keys[a] && keys[b]) {
  146. return true;
  147. }
  148. });
  149.  
  150. $(document.body).keyup(function (event) {
  151. // reset status of the button 'released' == 'false'
  152. if (event.keyCode == a) {
  153. keys[a] = false;
  154. } else if (event.keyCode == b) {
  155. keys[b] = false;
  156. }
  157. });
  158. }
  159.  
  160. function keyDtc() {
  161. // console.log(keyLis([17, 13]));
  162. keyLis([17, 13]);
  163. }
  164.  
  165. // if (keyLis([17, 13])) {
  166. // btnSendDsb();
  167. // msgShow("发送成功");
  168. // }
  169.  
  170. keyDtc();
  171. })();

QingJ © 2025

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