date: 2023-05-09 12:00:44
背景
在脚本官网查到了不少,关于力扣网站的脚本
- 有自动全屏的
- 有美化界面的
但是没有自动获取以往代码的。我习惯过(看一遍)题目,不喜欢自己点。
于是仿着之前的代码,蹩脚的写了一下js代码,但是不知道是放错了范围还是怎样,就是无法运行。
思路
为什么绑定在翻页按钮上,是因为自动全屏代码就执行一次,明明发生了重定向,可是不再执行,可我要求他提交确实每个页面都要提交的,不能只执行一次。
实现
只得自己把这段代码粘贴到F12的控制台里面。唉
// @require https://cdn.staticfile.org/jquery/2.1.4/jquery.min.js
// @require https://cdn.staticfile.org/jquery-cookie/1.4.1/jquery.cookie.min.js
// @require https://greasyfork.org/scripts/35940-my-jquery-plugin/code/My%20jQuery%20Plugin.js?version=234478
// @grant none
/* globals $ */
$('#prev-question-btn,#next-question-btn').on('click', function() {
console.log("g")
var showSolutionButton = null;
var solution = null;
var tijiao = null;
var submit = null;
var interval1 = setInterval(function() {
showSolutionButton = document.querySelector("path[d='M19 10.036a1 1 0 01-.586.874L8 15.644V20a1 1 0 11-2 0V4a1 1 0 011.479-.878l11 6a1 1 0 01.52.914zM8 13.447l7.762-3.528L8 5.685v7.762z']");
if (showSolutionButton ) {
if (showSolutionButton) {
showSolutionButton.parentNode.parentNode.click();
clearInterval(interval1);
}
}
}, 200);
var interval2=setInterval(function() {
solution = document.querySelector("body > div.modal-container.css-sdt3ue-RootContainer.e117yaqi0 > div > div.css-1qzxr3o-ContentContainer.e3tgp131 > div > div > div > div > div > div > div.ant-table-body > table > tbody > tr:nth-child(2) > td:nth-child(1) > label > span > span");
//console.log(solution+"选中啦")
if (solution) {
if (solution) {
solution.parentNode.parentNode.click();
//console.log(solution+"选中啦1")
tijiao = document.querySelector("body > div.modal-container.css-sdt3ue-RootContainer.e117yaqi0 > div > div.css-m5nivd-FooterContainer.e3tgp132 > div > button");
if (tijiao ) {
if (tijiao) {
tijiao.click();
clearInterval(interval2);
//console.log(tijiao+"确认啦")
}
}
}
}
},200);
});
1-4行是用的jQuery,还有油猴脚本的权限,以及域什么的。
然后就是通过绑定上一页,下一页的按钮,以及几个点击按钮。通过短暂的定时任务,来达到效果。
逻辑
点获取-》第一条-》点确定
效果
加那么多蹩脚的注释,是我真的不清楚,他为什么不能像自动全屏脚本那样进入就执行,然后运行。
使用方法
F12
把这些代码贴进去,回车