1p3a_script

方便使用一亩三分地

  1. // ==UserScript==
  2. // @name 1p3a_script
  3. // @namespace https://github.com/eagleoflqj/p1a3_script
  4. // @version 0.7.0.74
  5. // @description 方便使用一亩三分地
  6. // @author Liumeo
  7. // @match https://www.1point3acres.com/bbs/*
  8. // @grant GM_setValue
  9. // @grant GM_getValue
  10. // @grant GM_deleteValue
  11. // @require https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js
  12. // @require https://cdn.bootcss.com/jquery-cookie/1.4.1/jquery.cookie.js
  13. // @require https://gf.qytechs.cn/scripts/387976-1p3a-qa/code/1p3a_qa.js?version=743574
  14. // ==/UserScript==
  15.  
  16. (function () {
  17. 'use strict';
  18.  
  19. const jq = jQuery.noConflict();
  20. const waitUntilElementLoaded = function (element, retryTimes = 20) { // 异步等待元素出现并返回
  21. return new Promise((resolve, reject) => {
  22. const check = (ttl) => {
  23. const e = jq(element);
  24. if (!e.length && ttl) { // 未加载且未超时
  25. setTimeout(check, 1000, ttl - 1);
  26. } else {
  27. resolve(e); // 已加载或超时,返回jQuery对象
  28. }
  29. };
  30. check(retryTimes);
  31. });
  32. };
  33. (() => {
  34. const search_ids = ['planyr', 'planterm', 'planmajor', 'plandegree', 'planfin', 'result', 'country']; // 过滤下拉菜单id
  35. const replaceCookie = (c) => jq.cookie(c) && (GM_setValue(c, jq.cookie(c)) || 1) && jq.removeCookie(c); // 替换cookie为本地存储
  36. replaceCookie('searchoption');
  37. search_ids.forEach(replaceCookie);
  38. })();
  39. // 针对不同页面的操作
  40. const url = window.location.href;
  41. if (url === 'https://www.1point3acres.com/bbs/' || url.search('forum.php') > 0) { // 可签到、答题的页面
  42. // 自动签到
  43. const sign = jq('.wp a:contains("签到领奖")')[0];
  44. sign && sign.onclick && (sign.onclick() || 1) &&
  45. (async () => { // 点击签到领奖
  46. const qiandao = await waitUntilElementLoaded('#qiandao');
  47. if (!qiandao.length) {
  48. return;
  49. }
  50. const faces = qiandao.find('.qdsmilea>li'); // 所有表情
  51. const selected_face = faces[Math.floor(Math.random() * faces.length)]; // 随机选择表情
  52. selected_face.onclick();
  53. const todaysay = qiandao.find('#todaysay'); // 文字框
  54. todaysay.val('今天把论坛帖子介绍给好基友了~'); // 快速签到的第一句
  55. const button = qiandao.find('button')[0];
  56. button.onclick();
  57. })(); // 保证签到对话框加载
  58. // 签到后自动答题
  59. const dayquestion = jq('#um img[src*=ahome_dayquestion]').parent()[0];
  60. !sign && dayquestion && dayquestion.onclick && (dayquestion.onclick() || 1) &&
  61. (async () => {
  62. const fwin_pop = await waitUntilElementLoaded('#fwin_pop form');
  63. const question = fwin_pop.find('font:contains(【题目】)').text().slice(5);
  64. const prompt = '尚未收录此题答案。如果您知道答案,请将\n"\n' + question + '\n{您的答案}\n"\n以issue形式提交至https://github.com/eagleoflqj/p1a3_script/issues';
  65. const answer = QA[question];
  66. if (!answer) { // 题库不含此题
  67. console.log(prompt);
  68. return;
  69. }
  70. // 自动回答
  71. const option_list = [];
  72. const answer_list = typeof answer === 'string' ? [answer] : answer;
  73. // 答案和选项取交集
  74. fwin_pop.find('.qs_option').toArray()
  75. .forEach(option => answer_list
  76. .filter(answer => option.textContent.trim() === answer)
  77. .forEach(() => option_list.push(option)));
  78. if (!option_list.length) {
  79. console.log(prompt);
  80. return;
  81. }
  82. if (option_list.length > 1) {
  83. alert('[Warning] 多个选项与题库答案匹配');
  84. return;
  85. }
  86. option_list[0].onclick();
  87. jq('#seccodeverify_SA00')[0].focus();
  88. const button = fwin_pop.find('button')[0];
  89. // button.click(); // 提交答案
  90. console.log(question + '\n答案为:' + answer);
  91. })(); // 保证答题对话框加载
  92. }
  93. if (url.search('thread') > 0) { // 详情页
  94. // 自动查看学校、三维
  95. const elements = jq('.typeoption a:contains(点击查看)');
  96. elements.toArray().forEach(element => element.onclick());
  97. } else if (url.search('forum-82-1') > 0 || url.search('forum.php\\?mod=forumdisplay&fid=82') > 0) { // 结果汇报列表页
  98. // 按上次的筛选条件过滤录取结果
  99. const search_ids = ['planyr', 'planterm', 'planmajor', 'plandegree', 'planfin', 'result', 'country']; // 过滤下拉菜单id
  100. const search_button = jq('#searhsort > div.ptm.cl > button'); // 搜索按钮
  101. if (GM_getValue('searchoption')) { // 上次过滤了
  102. search_ids.forEach(id => jq('#' + id).val(GM_getValue(id)));// 自动填充下拉菜单
  103. if (url.search('filter') < 0) { // 当前页面没有过滤
  104. search_button.click(); // 自动过滤
  105. return;
  106. }
  107. }
  108. search_button.click(() => { // 如果不全是默认值,记下当前选项
  109. search_ids.some(id => jq('#' + id).val() !== '0') && GM_setValue('searchoption', 1);
  110. GM_getValue('searchoption') && search_ids.forEach(id => GM_setValue(id, jq('#' + id).val()));
  111. });
  112. // 添加重置按钮
  113. const reset_button = jq('<button type="button" class="pn pnc"><em>重置</em></button>');
  114. reset_button.click(() => { // 重置、清存储
  115. GM_deleteValue('searchoption');
  116. search_ids.forEach(id => {
  117. jq('#' + id).val('0');
  118. GM_deleteValue(id);
  119. });
  120. });
  121. search_button.after(reset_button);
  122. // 折叠占空间的提示
  123. const img = jq('#forum_rules_82_img')[0];
  124. img && img.src.search('collapsed_no') > 0 && img.onclick();
  125. }
  126. })();

QingJ © 2025

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