Created
January 4, 2021 14:29
-
-
Save Rhilip/07f1510ac1201e030a785570310be563 to your computer and use it in GitHub Desktop.
中国专利公布公告 PDF 版
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name 中国专利公布公告 PDF 版 | |
// @namespace blog.rhilip.info | |
// @version 0.1 | |
// @description 抛弃Flash,展示PDF | |
// @author Rhilip | |
// @match http://epub.sipo.gov.cn/pam.action | |
// @match http://epub.cnipa.gov.cn/pam.action | |
// @grant GM_xmlhttpRequest | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
let pdf_link = document.querySelector("a[href^='http://egaz.sipo.gov.cn/FileWeb/pfs?path=']").href | |
GM_xmlhttpRequest({ | |
method: 'GET', | |
url: pdf_link, | |
responseType:"arraybuffer", | |
headers: { | |
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9', | |
'Referer': 'http://epub.cnipa.gov.cn/' | |
}, | |
onload: function(r) { | |
var bb = new Blob([r.response], {type: 'application/pdf'}); | |
var fileURL = URL.createObjectURL(bb); | |
document.querySelector('iframe').src = fileURL | |
} | |
}); | |
// Your code here... | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment