Greasy Fork is available in English.
一款支持雨课堂网页版试卷导出成PDF的插件,简单易用。
当前为
// ==UserScript==
// @name 雨课堂网页版试卷试题导出到PDF
// @namespace http://tampermonkey.net/
// @version 1.0
// @description 一款支持雨课堂网页版试卷导出成PDF的插件,简单易用。
// @author 羽肿
// @match https://examination.xuetangx.com/*
// @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant none
// @license GPL
// ==/UserScript==
function p(e){
console.log(e)
}
var pageContent
function solve(){
pageContent = document.body.innerHTML;
//获取题目
let problemDomList = document.querySelectorAll(".clearfix p");
var problemList=[]
var list=['A','B','C','D']
for(var i=0;i<problemDomList.length;i++){
problemList.push(problemDomList[i].textContent.replace(/\n|\r/g, ""))
}
problemDomList = document.querySelectorAll('.clearfix:not(:has(p))');
for(i=1;i<problemDomList.length;i++){
problemList.push(problemDomList[i].textContent.replace(/\n|\r/g, ""))
}
var answerDomList= document.querySelectorAll(".radioText p");
var answerList=[]
for(i=0;i<answerDomList.length;i++){
answerList.push(answerDomList[i].textContent.replace(/\n|\r/g, " "))
}
var str=""
for(i=0;i<problemList.length;i++){
str+="第"+(i+1)+"题:"+problemList[i]
str+="\n"
for(var j=0;4*i+j<answerList.length&&j<4;j++){
str+=list[j]+"."+answerList[4*i+j]+"\n"
}
str+="\n"
}
document.body.innerHTML=str.replace(/\n/g, '<br>');
window.print()
}
(function() {
window.onload = function() {
setTimeout(function() {
solve()
document.body.innerHTML=pageContent
}, 2000);
};
})();