[Share] PDF深度查询 (PDF Depth Search) #124
MuiseDestiny
started this conversation in
Action Scripts
Replies: 1 comment 7 replies
-
Update: Now you can download pdf from SciHub with Zotero Action. Don't forget to update the available SciHub URL. Event: none // PDF深度查询
// @author Polygon
// @link https://github.com/windingwind/zotero-actions-tags/discussions/124
// @usage Menu Label=PDF深度查询
const ZoteroPane = require("ZoteroPane")
const Zotero = require("Zotero")
let DOI = ""
if (!item.isRegularItem()) {
return "不支持该类型"
} else if ((DOI = item.getField("DOI")).length == 0) {
return "无DOI不支持查询"
}
// scihub start
let parser = new DOMParser()
let scihubUrl = "https://sci-hub.se"
let url = `${scihubUrl}/${DOI}`
let resp = await Zotero.HTTP.request("GET", url)
let htmlDoc = parser.parseFromString(resp.responseText, "text/html")
let pdfTag = htmlDoc.querySelector("#pdf")
if (pdfTag) {
let pdfUrl = pdfTag.getAttribute("src")
if (pdfUrl.startsWith("//")) {
pdfUrl = "https:" + pdfUrl
} else if (pdfUrl.startsWith("/")) {
pdfUrl = scihubUrl + pdfUrl
}
let importOptions = {
libraryID: item.libraryID,
url: pdfUrl,
parentItemID: item.id,
title: "PDF_From_Scihub",
fileBaseName: "Full_Text_by_Action",
contentType: 'application/pdf',
referrer: url,
}
// result is an attachment item
let result = await Zotero.Attachments.importFromURL(importOptions)
if (result.key) {
return "SciHub 下载成功"
}
}
// open-access start if pdf can not found in scihub
Zotero.launchURL(
`https://www.open-access.xyz/?doi=${DOI}`
)
return "查询中..." |
Beta Was this translation helpful? Give feedback.
7 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Description
Search the paper's PDF on scidown using the DOI.
Action Settings
Event: none
Menu Label: PDF深度查询
Action: script
Data:
Tip
You can use
Add New File
to quickly add the pdf downloaded by the browser to the Zotero Item.It is Wondering File's function.
Beta Was this translation helpful? Give feedback.
All reactions