Greasy Fork is available in English.
Make filling wjx easier
当前为
// ==UserScript==
// @name WJX filler
// @namespace https://blog.csdn.net/SundaySmarty
// @version 1.0.0
// @description Make filling wjx easier
// @author SundaySmarty
// @match https://ks.wjx.top/*/*.aspx
// @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant none
// @license MIT
// ==/UserScript==
(function() {
'use strict';
// Basic structure
let fillerButton = document.createElement("button");
fillerButton.textContent = "WJX filler";
fillerButton.style.paddingLeft = "20px";
fillerButton.style.paddingRight = "20px";
fillerButton.style.height = "30px";
fillerButton.style.textAlign = "center";
fillerButton.style.background = "thistle";
fillerButton.style.color = "white";
fillerButton.style.border = "1px solid thistle";
fillerButton.style.borderRadius = "4px";
fillerButton.style.position = "fixed";
fillerButton.style.top = "0";
fillerButton.style.right = "0";
fillerButton.style.zIndex = "10000";
fillerButton.addEventListener("click", clickFillerButton);
let filler = document.createElement("div");
filler.style.width = "40%";
filler.style.height = "100%";
filler.style.background = "white";
filler.style.position = "fixed";
filler.style.top = "0";
filler.style.right = "0";
filler.style.display = "none";
filler.style.zIndex = "1000";
let fillerContainer = document.createElement("div");
fillerContainer.style.width = "100%";
fillerContainer.style.height = "100%";
fillerContainer.style.padding = "10%";
fillerContainer.style.overflowY = "auto";
fillerContainer.style.overflowX = "hidden";
let fillerHeader = document.createElement("div");
fillerHeader.style.width = "100%";
fillerHeader.style.textAlign = "center";
fillerHeader.style.margin = "5%";
let header = document.createElement("p");
header.innerHTML = "WJX filler";
header.style.fontSize = "24px";
header.style.fontWeight = "bold";
let contentContainer = document.createElement("div");
contentContainer.style.width = "100%";
document.body.appendChild(fillerButton);
document.body.appendChild(filler);
filler.appendChild(fillerContainer);
fillerContainer.appendChild(fillerHeader);
fillerHeader.appendChild(header);
fillerContainer.appendChild(contentContainer);
function clickFillerButton() {
if(filler.style.display == "none") {
filler.style.display = "block";
fillerButton.textContent = "Close";
}
else {
filler.style.display = "none";
fillerButton.textContent = "WJX filler";
}
}
// Find continuous multiple choice
let field = document.getElementsByClassName("field ui-field-contain");
let continuousMC = [];
let numOfMC = 0;
let firstMC = true;
let firstMCPos = 0;
let nAtALine = 15;
for(let i = 0; i < field.length; i++) {
if(field[i].getAttribute("type") == 3) {
numOfMC++;
if(firstMC) {
firstMC = false;
firstMCPos = i;
}
if(numOfMC % nAtALine == 0) {
continuousMC.push([firstMCPos, numOfMC]);
firstMC = true;
numOfMC = 0;
}
}
else {
if(numOfMC != 0 && numOfMC % nAtALine != 0) continuousMC.push([firstMCPos, numOfMC]);
firstMC = true;
numOfMC = 0;
}
}
if(numOfMC != 0 && numOfMC % nAtALine != 0) continuousMC.push([firstMCPos, numOfMC]);
if(continuousMC.length == 0) window.alert("No continuous multiple choice detected!");
// Show input
let MCInputList = [];
for(let i = 0; i < continuousMC.length; i++) {
let MCTitleContainer = document.createElement("div");
MCTitleContainer.style.width = "100%";
MCTitleContainer.style.margin = "5%";
let MCTitle = document.createElement("p");
MCTitle.innerHTML = field[continuousMC[i][0]].children[0].innerText.split('\n')[0] + '~' + field[continuousMC[i][0] + continuousMC[i][1] - 1].children[0].innerText.split('\n')[0];
let MCInputContainer = document.createElement("div");
MCInputContainer.style.width = "100%";
MCInputContainer.style.margin = "5%";
let MCInput = document.createElement("input");
MCInput.setAttribute("type", "text");
MCInput.style.width = "100%";
MCInput.style.height = "30px";
MCInput.style.fontSize = "20px";
contentContainer.appendChild(MCTitleContainer);
MCTitleContainer.appendChild(MCTitle);
contentContainer.appendChild(MCInputContainer);
MCInputContainer.appendChild(MCInput);
MCInputList.push(MCInput);
}
//SubmitButton
let submitButtonContainer = document.createElement("div");
submitButtonContainer.style.width = "100%";
submitButtonContainer.style.margin = "5%";
submitButtonContainer.style.textAlign = "center";
let submitButton = document.createElement("button");
submitButton.style.paddingLeft = "20px";
submitButton.style.paddingRight = "20px";
submitButton.style.height = "30px";
submitButton.textContent = "Confirm";
submitButton.addEventListener("click", clickSubmitButton);
contentContainer.appendChild(submitButtonContainer);
submitButtonContainer.appendChild(submitButton);
function clickSubmitButton() {
for(let i = 0; i < MCInputList.length; i++) {
if(MCInputList[i].value.length != continuousMC[i][1]) {
window.alert("Wrong Input!");
break;
}
else {
for(let j = 0; j < MCInputList[i].value.length; j++) {
let correctChoice = false;
for(let k = 0; k < field[continuousMC[i][0] + j].children[1].children.length; k++) {
if(field[continuousMC[i][0] + j].children[1].children[k].children[1].innerText == MCInputList[i].value[j].toUpperCase() || field[continuousMC[i][0] + j].children[1].children[k].children[1].innerText == MCInputList[i].value[j].toLowerCase()) {
field[continuousMC[i][0] + j].children[1].children[k].children[0].children[1].click();
correctChoice = true;
}
}
if(!correctChoice) {
window.alert("Wrong Input");
break;
}
}
}
}
}
})();