Skip to content

Commit

Permalink
20231009
Browse files Browse the repository at this point in the history
  • Loading branch information
liyuanhe211 committed Oct 9, 2023
1 parent 9be2cd2 commit 04e4a09
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 7 deletions.
19 changes: 18 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,23 @@ Developing this tool doesn't mean I support the piracy of scientific papers, nor

## Changelog

0.9 -
* Resolve URL substring matching vulnerability.
* Add support for DOI matching like https://pubs.rsc.org/en/content/articlelanding/2017/cc/c6cc05568k --> 10.1039/C6CC05568K

0.8 - 20231009
* Change default option to Sci-Hub as the Lib-Gen download servers are malfunctioning.
* Add more epdf sites to the direct-pdf list, the curren list include:
* https://pubs.acs.org/doi/epdf/*
* https://www.science.org/doi/epdf/*
* https://royalsocietypublishing.org/doi/epdf/*
* https://www.chinesechemsoc.org/doi/epdf/*
* https://www.pnas.org/doi/epdf/*
* https://onlinelibrary.wiley.com/doi/epdf/*
* https://journals.asm.org/doi/epub/*
* https://www.ahajournals.org/doi/epub*
* Removed redundant console warning about ERROR IGNORED for malformed URL.

0.7 - 20220307
* Fix Lib-Gen using domains having more than 2 characters like `libgen.rocks`

Expand Down Expand Up @@ -116,7 +133,7 @@ Developing this tool doesn't mean I support the piracy of scientific papers, nor
## Todo
* ~~Some of the [x-mol return pages](https://www.x-mol.com/q?option=Chemical%20Communications%202017,%2053%20(45)%20,%206054) doesn't directly give a DOI link, causing the automatic jump function could not be executed.~~
* ~~Changing the Lib-Gen page icon to reflect download status.~~
* (Probably solved, require long term testing by inspecting popup.html) Solve the "Unchecked runtime.lastError: QUOTA_BYTES_PER_ITEM quota exceeded" problem, which seems to appear after multiple pages are loaded.
* Solve the "Unchecked runtime.lastError: QUOTA_BYTES_PER_ITEM quota exceeded" problem, which seems to appear after multiple pages are loaded.
* ~~Query https://doi.crossref.org/simpleTextQuery for 10.1002/ange.19370502804 gives two duplicated download button.~~
* ~~Integrate https://doi.crossref.org/simpleTextQuery, https://search.crossref.org/ or similar CrossRef API. ~~
* Automatic update of usable Sci-Hub domains.
Expand Down
31 changes: 26 additions & 5 deletions lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,15 +230,34 @@ function match_doi(text)
if (is_URL(text))
{
let url_object = new URL(text)
if (url_object.host.endsWith("rsc.org"))
// Split the host into its sections
let hostParts = url_object.host.split('.');

// Check if the last two sections of the host are 'rsc.org'
if (hostParts.length >= 2
&& hostParts[hostParts.length - 2] === 'rsc'
&& hostParts[hostParts.length - 1] === 'org')
{
let doi = url_object.searchParams.get('DOI')
if (doi)
{
return "10.1039/"+doi
}
}

// https://pubs.rsc.org/en/content/articlelanding/2017/cc/c6cc05568k
const pattern = /cc\/([a-zA-Z0-9]+)/;
const matches = text.match(pattern);

// If the pattern matches, transform and return the string
if (matches && matches[1])
{
return `10.1039/${matches[1].toUpperCase()}`;
}
}



}

// Test situations for the doi matching function
Expand All @@ -258,7 +277,8 @@ function test_match_doi_function()
"DOI: 10.1021/acs.orglett.5b00297)",
'http://xlink.rsc.org/?DOI=C6CC05568K',
"https://lls.reaxys.com/xflink?aulast=Xu&title=Bioorganic%20and%20Medicinal%20Chemistry%20Letters&volume=29&issue=19&spage=&date=2019&coden=BMCLE&doi=10.1016%2Fj.bmcl.2019.126630&issn=1464-3405",
"https://www.thieme-connect.de/products/ejournals/pdf/10.1055/s-1997-1294.pdf"]
"https://www.thieme-connect.de/products/ejournals/pdf/10.1055/s-1997-1294.pdf",
"https://pubs.rsc.org/en/content/articlelanding/2017/cc/c6cc05568k"]

let answers = [undefined,
"10.1021/acs.orglett.5b00297",
Expand All @@ -274,17 +294,18 @@ function test_match_doi_function()
"10.1021/acs.orglett.5b00297",
"10.1039/C6CC05568K",
"10.1016/j.bmcl.2019.126630",
"10.1055/s-1997-1294"]
"10.1055/s-1997-1294",
"10.1039/C6CC05568K"]

console.log("-----------Test start-----------")
for (let i=0;i<test_cases.length;i++)
{
let test_case = test_cases[i]
let answer = answers[i]
if (match_doi(test_case)===answer)
console.log("PASS")
console.log("PASS",test_case,match_doi(test_case),answer)
else
console.log('FAIL',test_case,match_doi(test_case),answer)
console.log('FAILFAILFAIL',test_case,match_doi(test_case),answer)
}
console.log("-----------Test end-----------")
}
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "LYH DOI Tools",
"version": "0.8",
"version": "0.9",
"manifest_version": 3,
"description": "LYH DOI Tools",
"permissions": [
Expand Down

0 comments on commit 04e4a09

Please sign in to comment.