Created
August 2, 2022 09:16
-
-
Save qinlili23333/ea6ed58f8374f85339ed0cbbd4ce8f60 to your computer and use it in GitHub Desktop.
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 机械工业下载器 | |
// @namespace https://qinlili.bid | |
// @version 0.1 | |
// @description 劫持PDFJS下载 | |
// @author 琴梨梨 | |
// @match https://dcd.cmanuf.com/ebook/web/index.html* | |
// @grant none | |
// @run-at document-start | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
const dlFile = (link, name) => { | |
let eleLink = document.createElement('a'); | |
eleLink.download = name; | |
eleLink.style.display = 'none'; | |
eleLink.href = link; | |
document.body.appendChild(eleLink); | |
eleLink.click(); | |
document.body.removeChild(eleLink); | |
}; | |
let originConsole=console.log; | |
originConsole("Launching..."); | |
//劫持Uptodown的谷歌play按钮 | |
(function (appendChild) { | |
Node.prototype.appendChild = function (node) { | |
if (node.src&&node.src.indexOf("pdf_viewer.min.js")>0 ){ | |
alert("Hook Success!"); | |
originConsole("Ready..."); | |
let originGet=pdfjsLib.getDocument; | |
pdfjsLib.getDocument=doc=>{ | |
originConsole(doc); | |
dlFile(URL.createObjectURL(new Blob([doc.data])),Date.now()+".pdf") | |
return originGet(doc); | |
} | |
return appendChild.call(this, node); | |
} else { | |
return appendChild.call(this, node); | |
} | |
}; | |
})(Node.prototype.appendChild); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment