Skip to content

Commit

Permalink
修复更新功能bug
Browse files Browse the repository at this point in the history
  • Loading branch information
jiandandaoxingfu authored Jun 9, 2021
1 parent 5fcbb60 commit 2ef1af9
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 44 deletions.
21 changes: 0 additions & 21 deletions content-script/download-paper-button.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,3 @@
var source_url = "https://sci-hub.ren/";
var check_source_url_count = 0;

function get_source_url() {
if( check_source_url_count > 4 ) return;
check_source_url_count += 1;
let release_url = 'https://api.github.com/repos/jiandandaoxingfu/sci-hub-paper-download/releases';
axios.get(release_url).then( (res) => {
if( res.data[0] ) {
source_url = res.data[0].name;
console.log(source_url);
}
}).catch( e => {
console.log( '查询更新失败:' + e );
setTimeout( () => {
get_source_url();
}, 1000);
})
}
get_source_url();

let doi_;
let text;
let is_start = true;
Expand Down
24 changes: 1 addition & 23 deletions pages/download-paper/index.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,6 @@
var source_url = "https://sci-hub.ren/";
var check_source_url_count = 0;

function get_source_url() {
if( check_source_url_count > 4 ) return;
check_source_url_count += 1;
let release_url = 'https://api.github.com/repos/jiandandaoxingfu/scientific-research-assistant/releases';
axios.get(release_url).then( (res) => {
if( res.data[0] ) {
source_url = "https://sci-hub." + res.data.pop().name + "/";
console.log(source_url);
}
}).catch( e => {
console.log( '查询sci-hub地址失败:' + e );
setTimeout( () => {
get_source_url();
}, 1000);
})
}
get_source_url();


function download(input) {
let doi = input.value;
axios.get(source_url + doi)
axios.get("https://sci-hub.ren/" + doi)
.then( res => {
let url = res.data.replace(/(\n|\r\n|\r)/g, '').match(/['"]([^("|')]*?\.pdf.*?)['"]/);
if( !url || !url[1] ) {
Expand Down
1 change: 1 addition & 0 deletions popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>popup</title>
<link rel="stylesheet" type="text/css" href="popup.css">
<script type="text/javascript" src="pages/commonJs/axios.min.js"></script>
<script type="text/javascript" src="popup.js"></script>
</head>
<body>
Expand Down

0 comments on commit 2ef1af9

Please sign in to comment.