{"id":99,"date":"2024-01-22T17:26:31","date_gmt":"2024-01-22T09:26:31","guid":{"rendered":"https:\/\/blog.rensr.site\/?p=99"},"modified":"2024-01-23T17:37:30","modified_gmt":"2024-01-23T09:37:30","slug":"%e5%8d%8a%e8%87%aa%e5%8a%a8%e5%ad%a6%e4%b9%a0%e8%84%9a%e6%9c%ac","status":"publish","type":"post","link":"https:\/\/blog.rensr.site\/index.php\/2024\/01\/22\/%e5%8d%8a%e8%87%aa%e5%8a%a8%e5%ad%a6%e4%b9%a0%e8%84%9a%e6%9c%ac\/","title":{"rendered":"\u534a\u81ea\u52a8\u5b66\u4e60\u811a\u672c"},"content":{"rendered":"\n<p>\u5728\u5b66\u4e60\u8fc7\u7a0b\u4e2d\uff0c\u6211\u4eec\u7ecf\u5e38\u4f1a\u9047\u5230\u5927\u91cf\u7684\u5728\u7ebf\u8bfe\u7a0b\u9700\u8981\u5b8c\u6210\u3002\u8fd9\u4e9b\u8bfe\u7a0b\u6709\u4e9b\u9700\u8981\u624b\u52a8\u70b9\u51fb\u624d\u80fd\u5b8c\u6210\uff0c\u800c\u6709\u4e9b\u5219\u9700\u8981\u7b49\u5f85\u89c6\u9891\u64ad\u653e\u5b8c\u6bd5\u540e\u624d\u80fd\u81ea\u52a8\u8df3\u8f6c\u5230\u4e0b\u4e00\u8282\u8bfe\u7a0b\u3002\u56e0\u6b64\uff0c\u6211\u51b3\u5b9a\u7f16\u5199\u4e00\u4e2a\u534a\u81ea\u52a8\u5316\u7684\u5b66\u4e60\u811a\u672c\u6765\u63d0\u9ad8\u5b66\u4e60\u6548\u7387\u3002<\/p>\n\n\n\n<p>\u601d\u8def\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u9996\u5148\uff0c\u5728\u7528\u6237\u811a\u672c\u5143\u6570\u636e\u90e8\u5206\uff0c\u6211\u5b9a\u4e49\u4e86\u811a\u672c\u7684\u540d\u79f0\u3001\u7248\u672c\u53f7\u3001\u63cf\u8ff0\u7b49\u4fe1\u606f\u3002<\/li>\n\n\n\n<li>\u63a5\u7740\uff0c\u5728\u9875\u9762\u52a0\u8f7d\u5b8c\u6210\u540e\u7684\u56de\u8c03\u51fd\u6570\u4e2d\uff0c\u6211\u521b\u5efa\u4e86\u4e00\u4e2a\u65e5\u5fd7\u9762\u677f\uff0c\u5e76\u5c06\u5176\u6dfb\u52a0\u5230\u9875\u9762\u4e0a\u3002\u8fd9\u4e2a\u65e5\u5fd7\u9762\u677f\u7528\u4e8e\u8f93\u51fa\u65e5\u5fd7\u4fe1\u606f\u3002<\/li>\n\n\n\n<li>\u7136\u540e\uff0c\u6211\u4f7f\u7528querySelector\u67e5\u627e\u4e86\u9875\u9762\u4e0a\u7684&#8221;.stu_intro&#8221;\u5143\u7d20\uff0c\u5982\u679c\u627e\u5230\u4e86\u8fd9\u4e2a\u5143\u7d20\uff0c\u5c31\u83b7\u53d6\u5176\u4e2d\u7684\u6240\u6709&lt;li&gt;\u5143\u7d20\u3002<\/li>\n\n\n\n<li>\u5bf9\u4e8e\u6bcf\u4e2a&lt;li&gt;\u5143\u7d20\uff0c\u6211\u901a\u8fc7querySelector\u83b7\u53d6\u5176\u4e2d\u7684&lt;a&gt;\u5143\u7d20\u548c&lt;li&gt;\u5143\u7d20\uff0c\u5e76\u5206\u522b\u83b7\u53d6\u8bfe\u7a0b\u540d\u79f0\u548c\u72b6\u6001\u4fe1\u606f\u3002\u7136\u540e\uff0c\u6211\u5c06\u8bfe\u7a0b\u540d\u79f0\u548c\u72b6\u6001\u4fe1\u606f\u8f93\u51fa\u5230\u65e5\u5fd7\u9762\u677f\u4e2d\u3002<\/li>\n\n\n\n<li>\u5982\u679c\u72b6\u6001\u4e3a\u672a\u5b8c\u6210\uff0c\u6211\u5c31\u901a\u8fc7click()\u65b9\u6cd5\u70b9\u51fb&lt;a&gt;\u5143\u7d20\uff0c\u5e76\u5c06\u70b9\u51fb\u7684\u94fe\u63a5\u5730\u5740\u8f93\u51fa\u5230\u65e5\u5fd7\u9762\u677f\u4e2d\u3002<\/li>\n\n\n\n<li>\u63a5\u7740\uff0c\u6211\u4f7f\u7528querySelectorAll\u83b7\u53d6\u9875\u9762\u4e0a\u6240\u6709\u4ee5&#8221;javascript:ShowCourseware&#8221;\u5f00\u5934\u7684&lt;a&gt;\u5143\u7d20\u3002<\/li>\n\n\n\n<li>\u5bf9\u4e8e\u6bcf\u4e2a&lt;a&gt;\u5143\u7d20\uff0c\u6211\u901a\u8fc7getAttribute\u65b9\u6cd5\u83b7\u53d6\u5176href\u5c5e\u6027\u503c\uff0c\u7136\u540e\u5224\u65ad\u72b6\u6001\u662f\u5426\u4e3a&#8221;\u5df2\u5b8c\u6210&#8221;\u3002\u5982\u679c\u4e0d\u662f\uff0c\u5219\u901a\u8fc7click()\u65b9\u6cd5\u70b9\u51fb&lt;a&gt;\u5143\u7d20\uff0c\u5e76\u5c06\u70b9\u51fb\u7684\u94fe\u63a5\u5730\u5740\u8f93\u51fa\u5230\u65e5\u5fd7\u9762\u677f\u4e2d\u3002<\/li>\n\n\n\n<li>\u7136\u540e\uff0c\u6211\u4f7f\u7528querySelectorAll\u83b7\u53d6\u9875\u9762\u4e0a\u6240\u6709\u5e26\u6709&#8221;bg1&#8243;\u6216&#8221;bg2&#8243;\u7c7b\u540d\u7684\u5143\u7d20\uff0c\u5e76\u901a\u8fc7filter\u65b9\u6cd5\u7b5b\u9009\u51fa\u72b6\u6001\u4e3a&#8221;\u672a\u5f00\u59cb&#8221;\u6216&#8221;\u672a\u5b66\u5b8c&#8221;\u7684\u9879\u76ee\u3002<\/li>\n\n\n\n<li>\u5bf9\u4e8e\u7b5b\u9009\u51fa\u7684\u6bcf\u4e2a\u9879\u76ee\uff0c\u6211\u901a\u8fc7querySelector\u83b7\u53d6\u5176\u4e2d\u7684&lt;a&gt;\u5143\u7d20\uff0c\u5e76\u901a\u8fc7click()\u65b9\u6cd5\u70b9\u51fb&lt;a&gt;\u5143\u7d20\uff0c\u5e76\u5c06\u70b9\u51fb\u7684\u94fe\u63a5\u5730\u5740\u8f93\u51fa\u5230\u65e5\u5fd7\u9762\u677f\u4e2d\u3002<\/li>\n\n\n\n<li>\u63a5\u7740\uff0c\u6211\u4f7f\u7528setInterval\u5b9a\u65f6\u68c0\u67e5\u9875\u9762\u4e0a\u662f\u5426\u6709\u5f39\u7a97\uff0c\u5e76\u81ea\u52a8\u70b9\u51fb\u5f39\u7a97\u4e2d\u7684&#8221;\u662f&#8221;\u6309\u94ae\u3002\u6bcf\u969410\u79d2\u949f\u68c0\u67e5\u4e00\u6b21\uff0c\u5982\u679c\u6709\u5f39\u7a97\uff0c\u5219\u901a\u8fc7querySelector\u548cclick()\u65b9\u6cd5\u8fdb\u884c\u5904\u7406\uff0c\u5e76\u5c06\u70b9\u51fb\u7684\u65f6\u95f4\u548c\u4fe1\u606f\u8f93\u51fa\u5230\u65e5\u5fd7\u9762\u677f\u4e2d\u3002<\/li>\n\n\n\n<li>\u6700\u540e\uff0c\u6211\u5b9a\u4e49\u4e86\u4e00\u4e2a\u540d\u4e3acheckVideoStatus\u7684\u51fd\u6570\uff0c\u7528\u4e8e\u68c0\u67e5\u89c6\u9891\u64ad\u653e\u72b6\u6001\u3002\u5728\u51fd\u6570\u4e2d\uff0c\u6211\u901a\u8fc7querySelector\u83b7\u53d6\u89c6\u9891\u64ad\u653e\u65f6\u95f4\u7684\u663e\u793a\u533a\u57df\uff0c\u5e76\u5224\u65ad\u5f53\u524d\u65f6\u95f4\u662f\u5426\u7b49\u4e8e\u603b\u65f6\u95f4\u3002\u5982\u679c\u76f8\u7b49\uff0c\u8868\u793a\u89c6\u9891\u5df2\u7ecf\u64ad\u653e\u5b8c\u6bd5\uff0c\u5c06\u9875\u9762\u91cd\u5b9a\u5411\u5230\u6307\u5b9a\u94fe\u63a5\uff1b\u5426\u5219\uff0c\u8868\u793a\u89c6\u9891\u8fd8\u672a\u64ad\u653e\u5b8c\u6bd5\uff0c\u8f93\u51fa\u76f8\u5e94\u7684\u65e5\u5fd7\u4fe1\u606f\u3002<\/li>\n\n\n\n<li>\u6700\u540e\uff0c\u6211\u4f7f\u7528setInterval\u8bbe\u7f6e\u5b9a\u65f6\u5668\uff0c\u6bcf\u969410\u79d2\u949f\u8c03\u7528\u4e00\u6b21checkVideoStatus\u51fd\u6570\uff0c\u7528\u4e8e\u5faa\u73af\u68c0\u67e5\u89c6\u9891\u64ad\u653e\u72b6\u6001\u3002<\/li>\n<\/ol>\n\n\n\n<p>\u603b\u7ed3\uff1a \u901a\u8fc7\u7f16\u5199\u8fd9\u4e2a\u534a\u81ea\u52a8\u5316\u7684\u5b66\u4e60\u811a\u672c\uff0c\u53ef\u4ee5\u66f4\u52a0\u9ad8\u6548\u5730\u5b8c\u6210\u5728\u7ebf\u8bfe\u7a0b\u7684\u5b66\u4e60\u3002\u5728\u8fd9\u4e2a\u8fc7\u7a0b\u4e2d\uff0c\u6211\u4e3b\u8981\u4f7f\u7528\u4e86JavaScript\u548cDOM\u64cd\u4f5c\uff0c\u901a\u8fc7\u4e0d\u540c\u7684\u6761\u4ef6\u6765\u70b9\u51fb\u9875\u9762\u4e0a\u7684\u94fe\u63a5\uff0c\u5e76\u8f93\u51fa\u76f8\u5e94\u7684\u65e5\u5fd7\u4fe1\u606f\u3002\u540c\u65f6\uff0c\u6211\u4e5f\u52a0\u5165\u4e86\u5b9a\u65f6\u5668\uff0c\u5b9e\u73b0\u4e86\u4e00\u4e9b\u81ea\u52a8\u5316\u7684\u64cd\u4f5c\uff0c\u4f8b\u5982\u68c0\u67e5\u5f39\u7a97\u3001\u68c0\u67e5\u89c6\u9891\u64ad\u653e\u72b6\u6001\u7b49\u3002\u8fd9\u6837\u4e0d\u4ec5\u53ef\u4ee5\u63d0\u9ad8\u5b66\u4e60\u6548\u7387\uff0c\u540c\u65f6\u4e5f\u662f\u6211\u5bf9JavaScript\u548cDOM\u64cd\u4f5c\u7684\u4e00\u4e2a\u7ec3\u4e60\u548c\u63a2\u7d22\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ ==UserScript==\n\/\/ @name         \u5b66\u4e60\n\/\/ @namespace    https:\/\/rensr.site\n\/\/ @version      2024-01-22\n\/\/ @description  \u534a\u81ea\u52a8\u5b66\u4e60\n\/\/ @author       \u4efb\u5c1a\u4ec1\n\/\/ @match        https:\/\/\u5b66\u4e60\u5730\u5740\n\/\/ @icon         https:\/\/web.rensr.site\/assets\/img\/web-logo.png\n\/\/ @grant        none\n\/\/ ==\/UserScript==\n\n(function() {\n\t'use strict';\n\n\t\/\/ \u521b\u5efa\u65e5\u5fd7\u9762\u677f\n\tconst logPanel = document.createElement('div');\n\tlogPanel.style.position = 'fixed';\n\tlogPanel.style.top = '0';\n\tlogPanel.style.right = '0';\n\tlogPanel.style.width = '300px';\n\tlogPanel.style.height = '50%';\n\tlogPanel.style.backgroundColor = 'white';\n\tlogPanel.style.overflow = 'auto';\n\tdocument.body.appendChild(logPanel);\n\n\t\/\/ \u65e5\u5fd7\u8f93\u51fa\u51fd\u6570\n\tfunction log(message) {\n\t\tconst logMessage = document.createElement('p');\n\t\tlogMessage.textContent = message;\n\t\tlogPanel.appendChild(logMessage);\n\n\t\t\/\/ \u6ed1\u52a8\u6eda\u52a8\u6761\uff0c\u663e\u793a\u6700\u65b0\u6d88\u606f\n\t\tlogPanel.scrollTop = logPanel.scrollHeight;\n\t}\n\n\t\/\/ \u7b49\u5f85\u9875\u9762\u52a0\u8f7d\u5b8c\u6210\n\twindow.addEventListener('load', () => {\n\t\t\/\/ \u67e5\u627e stu_intro div\n\t\tvar stuIntroDiv = document.querySelector('.stu_intro');\n\n\t\tif (stuIntroDiv) {\n\t\t\t\/\/ \u5728 stu_intro div \u83b7\u53d6\u5168\u90e8\u7684&lt;li>\u5143\u7d20\n\t\t\tvar liElements = stuIntroDiv.getElementsByTagName('li');\n\n\t\t\t\/\/ \u70b9\u51fb\u72b6\u6001\u4e3a\u672a\u5b8c\u6210\u7684&lt;li>\u5143\u7d20\n\t\t\tfor (var i = 0; i &lt; liElements.length; i++) {\n\t\t\t\tvar linkElement = liElements&#91;i].querySelector('a');\n\t\t\t\tvar statusElement = liElements&#91;i].querySelector('i');\n                var courseName = linkElement.textContent;\n                var courseStatus = statusElement.innerText;\n                \/\/ \u8f93\u51fa\u8bfe\u7a0b\u548c\u72b6\u6001\n                log('\u8bfe\u7a0b\uff1a' + courseName);\n                log('\u72b6\u6001\uff1a' + courseStatus);\n\t\t\t\tif (linkElement &amp;&amp; statusElement &amp;&amp; statusElement.innerText === '&#91;\u672a\u5b8c\u6210]') {\n\t\t\t\t\tlinkElement.click();\n\t\t\t\t\tlog('\u70b9\u51fb\u4e86\u94fe\u63a5\uff1a' + href);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t\/\/ \u83b7\u53d6\u6240\u6709\u7684&lt;a>\u5143\u7d20\n\t\tconst linkElements = document.querySelectorAll('a&#91;href^=\"javascript:ShowCourseware\"]');\n\t\t\/\/ \u904d\u5386\u6bcf\u4e2a&lt;a>\u5143\u7d20\n\t\tlinkElements.forEach((linkElement) => {\n\t\t\tconst statusText = linkElement.getAttribute('href')\n\t\t\t\t.match(\/'(&#91;^']+)'\/)&#91;1];\n\t\t\tif (statusText !== '\u5df2\u5b8c\u6210') {\n\t\t\t\t\/\/ \u70b9\u51fb\u94fe\u63a5\n\t\t\t\tlinkElement.click();\n\t\t\t\tlog('\u70b9\u51fb\u4e86\u94fe\u63a5\uff1a' + linkElement.getAttribute('href'));\n\t\t\t}\n\t\t});\n\n\t\t\/\/ \u83b7\u53d6\u6240\u6709\u672a\u5f00\u59cb\u7684\u9879\u76ee\n\t\tconst rows = document.querySelectorAll('tr.bg1, tr.bg2');\n\t\tconst unfinishedItems = Array.from(rows)\n\t\t\t.filter(row => {\n\t\t\t\tconst status = row.querySelector('td:nth-child(3) span')\n\t\t\t\t\t.textContent.trim();\n\t\t\t\treturn status === '\u672a\u5f00\u59cb' || status === '\u672a\u5b66\u5b8c';\n\t\t\t});\n\n\t\t\/\/ \u70b9\u51fb\u672a\u5f00\u59cb\u7684\u9879\u76ee\n\t\tunfinishedItems.forEach(item => {\n\t\t\tconst link = item.querySelector('a');\n\t\t\tif (link) {\n\t\t\t\tlink.click();\n\t\t\t\tlog('\u70b9\u51fb\u4e86\u94fe\u63a5\uff1a' + link.getAttribute('href'));\n\t\t\t}\n\t\t});\n\n\t\t\/\/ \u68c0\u67e5\u5f39\u7a97\u5e76\u81ea\u52a8\u70b9\u51fb\u201c\u662f\u201d\n\t\tsetInterval(function() {\n\t\t\tconst popup = document.querySelector('.school-sate');\n\t\t\tif (popup) {\n\t\t\t\tconst yesButton = popup.querySelector('button:nth-of-type(1)');\n\t\t\t\tif (yesButton) {\n\t\t\t\t\tyesButton.click();\n\t\t\t\t\tlog('&#91;' + new Date()\n\t\t\t\t\t\t.toLocaleString() + '] ' + '\u70b9\u51fb\u4e86\u2018\u662f\u2019\u6309\u94ae');\n\t\t\t\t}\n\t\t\t}\n\t\t\tlog('&#91;' + new Date()\n\t\t\t\t.toLocaleString() + '] ' + '\u6b63\u5728\u68c0\u67e5\u5728\u7ebf\u5f39\u7a97...');\n\t\t}, 10000);\n\n\t\t\/\/ \u68c0\u67e5\u89c6\u9891\u64ad\u653e\u72b6\u6001\n\t\tfunction checkVideoStatus() {\n\t\t\tconst timeDisplay = document.querySelector('.prism-time-display');\n\t\t\tif (timeDisplay) {\n\t\t\t\tconst currentTime = timeDisplay.querySelector('.current-time')\n\t\t\t\t\t.textContent;\n\t\t\t\tconst duration = timeDisplay.querySelector('.duration')\n\t\t\t\t\t.textContent;\n\n\t\t\t\tlog(`\u5f53\u524d\u65f6\u95f4: ${currentTime} \/ \u603b\u65f6\u95f4: ${duration}`);\n\n\t\t\t\tif (currentTime === duration) {\n\t\t\t\t\tlog('\u89c6\u9891\u5df2\u7ecf\u64ad\u653e\u5b8c\u6bd5');\n\t\t\t\t\twindow.location.href = '\u8df3\u8f6c\u5230\u5b66\u4e60\u9996\u9875';\n\t\t\t\t} else {\n\t\t\t\t\tlog('\u89c6\u9891\u8fd8\u672a\u64ad\u653e\u5b8c\u6bd5');\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tsetInterval(checkVideoStatus, 10000); \/\/ \u6bcf10\u79d2\u949f\u6267\u884c\u4e00\u6b21\u5224\u65ad\n\t});\n})();<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u5728\u5b66\u4e60\u8fc7\u7a0b\u4e2d\uff0c\u6211\u4eec\u7ecf\u5e38\u4f1a\u9047\u5230\u5927\u91cf\u7684\u5728\u7ebf\u8bfe\u7a0b\u9700\u8981\u5b8c\u6210\u3002\u8fd9\u4e9b\u8bfe\u7a0b\u6709\u4e9b\u9700\u8981\u624b\u52a8\u70b9\u51fb\u624d\u80fd\u5b8c\u6210\uff0c\u800c\u6709\u4e9b\u5219\u9700\u8981\u7b49\u5f85\u89c6\u9891\u64ad\u653e [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-99","post","type-post","status-publish","format-standard","hentry","category-my-project"],"_links":{"self":[{"href":"https:\/\/blog.rensr.site\/index.php\/wp-json\/wp\/v2\/posts\/99","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.rensr.site\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.rensr.site\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.rensr.site\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.rensr.site\/index.php\/wp-json\/wp\/v2\/comments?post=99"}],"version-history":[{"count":3,"href":"https:\/\/blog.rensr.site\/index.php\/wp-json\/wp\/v2\/posts\/99\/revisions"}],"predecessor-version":[{"id":103,"href":"https:\/\/blog.rensr.site\/index.php\/wp-json\/wp\/v2\/posts\/99\/revisions\/103"}],"wp:attachment":[{"href":"https:\/\/blog.rensr.site\/index.php\/wp-json\/wp\/v2\/media?parent=99"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.rensr.site\/index.php\/wp-json\/wp\/v2\/categories?post=99"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.rensr.site\/index.php\/wp-json\/wp\/v2\/tags?post=99"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}