// ==UserScript== // @name 国家中小学智慧教育平台书籍下载 // @namespace https://github.com/hmjz100/ // @version 0.3 // @description 自动跳转到PDF页面,精简页面 // @author Hmjz100 // @match *://basic.smartedu.cn/* // @match *://*.zxx.edu.cn/* // @icon https://basic.smartedu.cn/favicon.ico // @license MIT // @require https://cdn.jsdelivr.net/npm/sweetalert2@11/dist/sweetalert2.all.min.js // @downloadURL none // ==/UserScript== (function () { 'use strict'; var html = location.href; var toast = Swal.mixin({ imageUrl: 'https://basic.smartedu.cn/img/logo-new.59a73b97.png', allowOutsideClick: false, showConfirmButton: false, timer: 3000, timerProgressBar: true, }); var message = { success: function (text) { toast.fire({ html: text, icon: 'success' }); }, error: function (text) { toast.fire({ html: text, icon: 'error' }); }, warning: function (text) { toast.fire({ html: text, icon: 'warning' }); }, info: function (text) { toast.fire({ html: text, icon: 'info' }); }, question: function (text) { toast.fire({ html: text, icon: 'question' }); } }; function repair(i) { if (i >= 0 && i <= 9) { return "0" + i; } else { return i; } } function timer() { var date = new Date(); var year = date.getFullYear(); var month = repair(date.getMonth() + 1); var day = repair(date.getDate()); var hours = repair(date.getHours()); var minute = repair(date.getMinutes()); var second = repair(date.getSeconds()); var curTime = year + "年 - " + month + "月 - " + day + "日  " + hours + "时 : " + minute + "分 : " + second + "秒"; return curTime; } function APM() { var date = new Date(); var hour = date.getHours(); var hourtext = ''; if (hour >= 0 && hour <= 10) { hourtext = '早上好'; } else if (hour > 10 && hour <= 14) { hourtext = '中午好'; } else if (hour > 14 && hour <= 18) { hourtext = '下午好'; } else if (hour > 18 && hour <= 24) { hourtext = '晚上好'; } return hourtext; } if (html !== null && html.indexOf("goTip") != -1) { var clickurl = document.getElementsByClassName("index-module_open_1MwDX"); if (clickurl) { message.info("正在加载PDF页面请稍等
请不要进行任何操作直至PDF打开!
"); setTimeout(function () { clickurl[0].click(); }, 5000); } } var notice = document.getElementsByClassName('index-module_header-content_Usvn5'); if (notice) { setTimeout(function () { notice[0].innerHTML += '
' + APM() + ',当前时间:时间加载中  感谢您使用本脚本!
'; var time = document.getElementById('time'); if (time) { window.setInterval(function () { time.innerHTML = timer(); }, 500); } }, 2000); } console.log('[国家中小学智慧教育平台书籍下载]脚本运行成功'); var topbar = document.getElementsByClassName("index-module_download-bar_1ZRtf theme-bar"); if (topbar) { topbar[0].remove(); } function GetUrl() { if (html !== null && html.indexOf("catalogType") != -1) { return html.replace(/&catalogType+=[A-Za-z0-9]+/, ""); } } function GetLastUrl() { if (html !== null && html.indexOf("assets_document") != -1) { return GetUrl().replace("assets_document", "x_url"); } } if (html !== null && html.indexOf("assets_document") != -1) { message.success("已替换该页面的书籍地址,正在加载PDF页面请稍等。"); setTimeout(function () { window.onload = window.location.href = GetLastUrl(); }, 3000); } })();