分享个gb688下载pdf的油猴脚本
导读
gb688不能直接下载pdf了 在GitHub上找了个脚本 分享给大家
// ==UserScript==
// @name gb688下载
// @namespace https://github.com/lzghzr/TampermonkeyJS
// @version 1.0.7
// @author lzghzr, chorar
// @description 下载gb688.cn上的国标文件
// @supportURL https://github.com/lzghzr/TampermonkeyJS/issues
// @match *://*.gb688.cn/bzgk/gb/showGb*
// @match *://*.samr.gov.cn/bzgk/gb/showGb*
// @connect c.gb688.cn
// @license MIT
// @grant none
// ==/UserScript==
(function() {
'use strict';
const online = document.getElementById("toolbarViewerRight");
if (online === null) {
throw '获取页面元素失败!';
}
const download = document.querySelector('button.toolbarButton.download');
if (download !== null) {
download.remove();
}
const GBdownload = document.createElement('button');
GBdownload.title = '下载';
GBdownload.className = 'toolbarButton download';
GBdownload.innerHTML = '下载';
online.insertAdjacentElement('afterbegin', GBdownload);
GBdownload.onclick = async () => {
PDFViewerApplication.pdfDocument.seDocument(PDFViewerApplication.pdfDocument.annotationStorage).then(res =>{
const blob = new Blob([res], { type: "application/pdf" });
const blobUrl = URL.createObjectURL(blob);
const a = document.createElement("a");
a.href = blobUrl;
a.target = "_parent";
a.download = document.title.substr(document.title.indexOf('|')+1).replace("/", '_')+".pdf";
(document.body || document.documentElement).appendChild(a);
a.click();
}).catch(err =>{
console.log(err)
});
};
})();复制代码
把复制的代码放进去保存即可 效果图