您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
好好学习
// ==UserScript== // @name 职业标准系统PDF下载 // @namespace http://biaozhun.osta.org.cn/ // @version 0.4 // @description 好好学习 // @author vonsy // @match http://biaozhun.osta.org.cn/ // @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw== // @grant none // @run-at document-idle // @license 版权没有,违者不究 // ==/UserScript== window.onload = function() { 'use strict'; let get = 'http://biaozhun.osta.org.cn/api/v1/profession/get/'; let all = document.querySelectorAll('.table_data'); for (let i = 0; i < all.length; i++) { let href = all[i].lastElementChild.firstElementChild.href let url = new URL(href); let code = url.searchParams.get("code"); let name = all[i].children[2].textContent; var link = document.createElement("a"); link.className = "download"; link.innerText = name + '---> PDF下载'; link.href = 'javascript:void(0)'; link.addEventListener('click', ()=>{ console.log('下载' + name + 'PDF文件'); let xhr = new XMLHttpRequest(); let req = get + code; xhr.open("GET", req, false); xhr.onload = function(event){ let response = event.target.response; let pdf = JSON.parse(response); console.log('名称: ' + name); console.log('编号: ' + code); console.log('反馈结果: ' + pdf.msg); console.log('反馈编码: ' + pdf.code); let pdfWindow = window.open("") pdfWindow.document.write( "<iframe width='100%' height='100%' src='data:application/pdf;base64, " + encodeURI(pdf.data) + "'></iframe>" ) }; xhr.send(); }); all[i].children[2].textContent = ''; all[i].children[2].appendChild(link); } };