某高校课标页面简化脚本

    科技2022-07-17  135

    1.动机

    学校的网站永远是那么的有个性,电脑还好,手机看课标就比较费眼睛。所以写了个脚本。

    2.功能

    1).自动填充账号密码并登陆

    2).自动点击进入课表页面

    3).课表页面简化

    3.效果

    PC端,修改前PC端,修改后

     

     

    手机端,修改前手机端,修改后

     

     

    4.脚本

    1. 课表页面精简

    // ==UserScript== // @name 跳转到课表并整理页面 // @namespace http://tampermonkey.net/ // @version 0.1 // @description try to take over the world! // @author You // @match 查课表网站域名 // @grant none // @run-at document-end // ==/UserScript== (function() { 'use strict'; var t1= setInterval(click_table,200); var t2; function click_table(){ document.body.style="background-color:#fefefe"; var ele=document.getElementsByClassName("swiper-slide swiper-slide-visible"); if(ele.length>1){ ele[1].children[0].click(); t2= setInterval(fix_page_if, 200); clearInterval(t1); } } function fix_page_if(){ var e=document.getElementsByClassName("datagrid-cell"); console.log(e.length); if(e.length>110){ fix_page(); clearInterval(t2); } } function fix_page(){ var e=document.getElementsByTagName("tbody"); var newstr= e[8].innerHTML; newstr= newstr.toString(); //移除所有元素 document.head.remove(); document.lastElementChild.className=""; var chls= document.body.children; for(var i=chls.length; i>0;i-- ){ chls[i-1].remove(); } //添加表格首行的空格 newstr= newstr.replace(/<tbody>/i, ""); newstr= /<tr.+?\/tr>/i.exec(newstr )[0]+ newstr; newstr= "<tbody>"+ newstr; //去除id newstr= newstr.replace(/id=.+?<td/ig, "><td"); //去除div newstr= newstr.replace(/<div.+?>/ig, ""); newstr= newstr.replace(/<\/div>/ig, ""); //添加行首周数 var t_body = document.createElement("tbody"); var t_able = document.createElement("table"); t_body.innerHTML= newstr; t_able.style="border-collapse: collapse;color:#050505;font-size:16px; width:90%;margin : 6% 5% 5% 5%;" t_able.border="3px solid"; t_able.cellpadding="20px"; var head=t_body.children[0].children; var text_=["节次","周一","周二","周三","周四","周五","周六","周日"]; for(i=head.length;i>0;i--){ head[i-1].innerText= text_[i-1]; } //document.head.remove() document.body.appendChild(t_able); t_able.appendChild(t_body); } // Your code here... })();

    2.自动填充密码并登陆

    // ==UserScript== // @name 自动登录???? // @namespace http://tampermonkey.net/ // @version 0.1 // @description try to take over the world! // @author You // @match 域名 // @match 域名 // @grant none // ==/UserScript== (function() { 'use strict'; function click_id(id_name){ var e= document.getElementById(id_name); if(e!= null){ e.click(); } } function click_class(class_name, index_min, index_max){ var e= document.getElementsByClassName(class_name); if(e.length>index_max){ var i=0; for(i=index_min; i<= index_max; i++){ e[i].click(); } } } function input_id(id_name, value){ var e= document.getElementById(id_name); if(e!= null){ e.value=value; } } click_class("dlunibtn", 0, 0); input_id("un",[学号]); input_id("pd",[密码]); click_id("index_login_btn"); // Your code here... })();

     

    Processed: 0.011, SQL: 8