Skip to content

Instantly share code, notes, and snippets.

@hui-shao
Last active December 28, 2022 13:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hui-shao/e5d581a42286b1ba34bbec2cdecd6790 to your computer and use it in GitHub Desktop.
Save hui-shao/e5d581a42286b1ba34bbec2cdecd6790 to your computer and use it in GitHub Desktop.
MOOC互评辅助,解放双手
// ==UserScript==
// @name MOOC互评辅助
// @namespace https://github.com/hui-shao
// @version 0.2
// @description 一键填充了属于是!
// @author Hui-Shao
// @license GPLv3
// @match *://www.icourse163.org/spoc/learn/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=icourse163.org
// @grant none
// ==/UserScript==
(function() {
'use strict';
// Your code here...
var button,observe;
function createButton() {
//alert("btn");
button = document.createElement("button");
button.id = "btn001";
button.textContent = "一键评分";
button.className = "u-btn u-btn-default";
button.style.position = "fixed";
button.style.right = "50px";
button.style.bottom = "50px";
button.style.display = "none";
button.onclick = function () {
myInput();
};
document.querySelector(".m-learnbox").appendChild(button);
}
function myInput() {
var lst_1 = document.getElementsByTagName("textarea");
for (let i = 0; i < lst_1.length; i++)
{
lst_1[i].value = "1";
}
var lst_2 = document.querySelectorAll(".detail .s");
for (let i = 0; i < lst_2.length; i++)
{
lst_2[i].lastElementChild.firstElementChild.checked = true;
}
// Scroll to bottom
var e = document.documentElement;
e.scrollTo(e.scrollLeft,e.scrollHeight);
//alert("[Script] 执行完毕.");
}
function showOrHide(){
if(window.location.hash.indexOf("hw")!=-1){
button.style.display = "";
}
else{
button.style.display = "none";
}
}
window.onload = function(){
// alert("[Script] ready");
createButton();
setInterval(showOrHide, 500);
};
})();
@hui-shao
Copy link
Author

一行版本,互评页面下直接粘贴进Console执行:

var lst_1=document.getElementsByTagName("textarea");for(let i=0;i<lst_1.length;i++){lst_1[i].value="1"}var lst_2=document.querySelectorAll(".detail .s");for(let i=0;i<lst_2.length;i++){lst_2[i].lastElementChild.firstElementChild.checked=true}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment