NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name 步步高批量下载 // @namespace http://tampermonkey.net/ // @version 0.1 // @description 进入你想下的图书页面-刷新-即可看到下载url! // @author ORDYLAN // @match https://www.xinjiaoyu.com/teacher/digital_books/detail* // @require https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.1.1/crypto-js.min.js // @grant none // @license MIT // ==/UserScript== var key = "6f0c5ba452b24fa28989e9524d77407a";//花6+h提取的key function decrypt(ciphertext, key) { var keyBytes = CryptoJS.enc.Utf8.parse(key); var decrypted = CryptoJS.AES.decrypt({ ciphertext: CryptoJS.enc.Base64.parse(ciphertext.replace(/[\r\n]/g, "")) }, keyBytes, { mode: CryptoJS.mode.ECB, padding: CryptoJS.pad.Pkcs7 }); return decrypted.toString(CryptoJS.enc.Utf8); } function getUrlParameter(name) { name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]'); var regex = new RegExp('[\\?&]' + name + '=([^&#]*)'); var results = regex.exec(location.search); return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' ')); }; function fetchData(bookId) { var apiUrl = 'https://www.xinjiaoyu.com/api/v3/server_resource/ebook/book/resource?ebookBookId=' + bookId; var headers = new Headers({ 'Accept': 'application/json, text/plain, */*', 'Accept-Encoding': 'gzip, deflate, br, zstd', 'Accept-Language': 'zh-CN,zh;q=0.9,en;q=0.8', 'Cache-Control': 'no-cache', 'Connection': 'keep-alive', 'Pragma': 'no-cache', 'Sec-Fetch-Dest': 'empty', 'Sec-Fetch-Mode': 'cors', 'Sec-Fetch-Site': 'same-origin', 'client': 'front', 'clientSession': 'TGggZg82V', 'encrypt': '1', 't': '1' }); fetch(apiUrl, { method: 'GET', headers: headers }).then(response => { if (!response.ok) { throw new Error('Network response was not ok'); } return response.json(); }) .then(data => { console.log('Received JSON data:', data); localStorage.T_url= JSON.stringify(data); parseJson(data); }) .catch(error => { console.error('Error fetching data:', error); }); } var tableContainer = document.createElement('div'); tableContainer.style.position = 'absolute'; tableContainer.style.top = '40%'; tableContainer.style.left = '0'; tableContainer.style.width = '100%'; tableContainer.style.background = '#fff'; // 设置背景颜色 tableContainer.style.zIndex = '9999'; // 确保表格在顶部 tableContainer.style.overflow = "auto"; var table = document.createElement('table'); table.style.width = '100%'; var tableHead = document.createElement('thead'); var tableBody = document.createElement('tbody'); tableBody.id = 'tableBody'; // 给tbody设置一个id,以便后续填充数据 var tableHeadRow = document.createElement('tr'); var tableHeadCell1 = document.createElement('th'); var tableHeadCell2 = document.createElement('th'); tableHeadCell1.textContent = 'Ebook Resource Name'; tableHeadCell2.innerHTML = 'Link Address'; tableHeadRow.appendChild(tableHeadCell1); tableHeadRow.appendChild(tableHeadCell2); tableHead.appendChild(tableHeadRow); table.appendChild(tableHead); table.appendChild(tableBody); tableContainer.appendChild(table); // Append the table container to the document body document.body.appendChild(tableContainer); var divElement = document.createElement("div"); divElement.id = "wgetCommandsDiv"; tableContainer.appendChild(divElement); function generateWgetCommand(linkAddress, ebookResourceName) { // 获取链接地址中的文件后缀名 var fileExtension = linkAddress.split('.').pop().split('?')[0]; // 构建 wget 命令 var wgetCommand = 'wget -O ' + ebookResourceName + '.' + fileExtension + ' "' + linkAddress + '"'; var preElement = document.createElement('pre'); preElement.textContent = wgetCommand; // 将 <pre> 元素添加到指定的 <div> 中 var divElement = document.getElementById("wgetCommandsDiv"); divElement.appendChild(preElement); } var preElement = document.createElement('pre'); preElement.textContent = "chcp 65001"; var daivElement = document.getElementById("wgetCommandsDiv"); daivElement.appendChild(preElement); function parseJson(jsonData) { var data = jsonData.data; var tableBody = document.getElementById('tableBody'); tableBody.innerHTML = ''; data.forEach(function(item) { var ebookResourceName = item.ebookResourceName; var linkAddress = item.linkAddress; var row = document.createElement('tr'); var nameCell = document.createElement('td'); var linkCell = document.createElement('td'); nameCell.textContent = ebookResourceName; linkAddress = decrypt(linkAddress, key); var link = document.createElement('a'); link.href = linkAddress; link.textContent = linkAddress; link.target = "_blank"; linkCell.appendChild(link); row.appendChild(nameCell); row.appendChild(linkCell); tableBody.appendChild(row); generateWgetCommand(linkAddress, ebookResourceName) }); } var bookId = getUrlParameter('bookId'); fetchData(bookId);