From 2c6364a4b79a019bdbafe89b900d41fb3e151683 Mon Sep 17 00:00:00 2001 From: redleafnew Date: Sat, 11 Jun 2022 15:11:45 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=B8=BA0.0.2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 4 +- chrome/content/scripts/zoteroupdateifs.js | 151 ++++++++++++++++------ release.sh | 6 +- 3 files changed, 116 insertions(+), 45 deletions(-) diff --git a/README.md b/README.md index 973a5c1..9a90526 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ 插件功能与[Zotero Update IFs](https://github.com/redleafnew/zotero-updateifs)相同,代码逻辑也一样,为了防止冲突,请不要同时安装这两个插件。[Zotero Update IFs](https://github.com/redleafnew/zotero-updateifs)期刊缩写功能可见[Delete Item(s) With Attachment(s)](https://github.com/redleafnew/delitemwithatt)插件。 -1. 使用期刊名称从[easyScholar](https://easyscholar.cc)更新期刊英文期刊的`JCR分区`、`中科院分区`、`影响因子`和`5年影响因子`,对于中文期刊更新是否`CSCD收录`、`北大核心`、`科技核心`;更新期刊是否`EI收录`;插件主体来源于`Zotero Scholar Citations`(),插件安装后在分类及条目上右击会出现`从easyScholar更新期刊信息`,点击即可从[easyScholar](https://easyscholar.cc)获取`JCR分区`、`中科院分区`、`影响因子`和`5年影响因子`及中文期刊更新是否南`南农大核心期刊`、`南农大高质量期刊(仅含食品科学与工程)`、`CSCD收录`、`北大/南大核心`、`科技核心`、`EI`,并分别写入到`档案`、`存档位置`、`馆藏目录`、`索书号`、`版权`字段(可进行设置是否显示和存贮位置),也可以设置以上信息是否保存在`Extra`字段(默认为不保存)。。 +1. 根据条目语言(语言字段包括`en`为英文条目,语言设置可以使用[Delitem插件](https://github.com/redleafnew/delitemwithatt))使用期刊名称从[easyScholar](https://easyscholar.cc)更新期刊英文期刊的`JCR分区`、`中科院分区`、`影响因子`、`5年影响因子`和`EI`;对于中文期刊更新是否`EI`、`CSCD收录`、`中文核心期刊/北大核心`、`CSSCI/南大核心`、`中国科技核心期刊`;插件主体来源于`Zotero Scholar Citations`(),插件安装后在分类及条目上右击会出现`从easyScholar更新期刊信息`,点击即可从[easyScholar](https://easyscholar.cc)获取`JCR分区`、`中科院分区`、`影响因子`和`5年影响因子`及中文期刊更新是否南`南农大核心期刊`、`南农大高质量期刊(仅含食品科学与工程)`、`CSCD收录`、`北大/南大核心`、`科技核心`、`EI`,并分别写入到`档案`、`存档位置`、`馆藏目录`、`索书号`、`版权`字段(可进行设置是否显示和存贮位置),也可以设置以上信息是否保存在`Extra`字段(默认为不保存),如果显示不正常请先清除`其它`(`Extra`)字段。 2. 清除`其它`字段内容(`工具`-`清除其它内容...`)。 @@ -16,7 +16,7 @@ -1. Update `JCR Quartile`, `CAS Quartile`, `impact factor` and `5 year impact factor` using name of the journal from [easyScholar](https://easyscholar.cc). The framework of the present plugin is from `Zotero Scholar Citations`(). A context menu `Update Journal Infomation from easyScholar` appears, the `JCR Quartile`, `CAS Quartile`, `impact factor` and `5 year impact factor` will be fetched from [easyScholar](https://easyscholar.cc) and stored into the `Archive`, `Loc. in Archive`, `Library Catalog`, `Call Number`, `Rights` field (you can set show or not and the target field) if it doesn't work, the information abovementioned can be set to saved to `Extra` field(default false). +1. Update `JCR Quartile`, `CAS Quartile`, `impact factor`, `5 year impact factor` and `EI` using name of the journal from [easyScholar](https://easyscholar.cc). The framework of the present plugin is from `Zotero Scholar Citations`(). A context menu `Update Journal Infomation from easyScholar` appears, the `JCR Quartile`, `CAS Quartile`, `impact factor` and `5 year impact factor` will be fetched from [easyScholar](https://easyscholar.cc) and stored into the `Archive`, `Loc. in Archive`, `Library Catalog`, `Call Number`, `Rights` field (you can set show or not and the target field) if it doesn't work, the information abovementioned can be set to saved to `Extra` field(default false). 2. Remove `Extra` field content (`Tools`-`Clean Extra Field...`). diff --git a/chrome/content/scripts/zoteroupdateifs.js b/chrome/content/scripts/zoteroupdateifs.js index e8ba3ba..7d43f82 100644 --- a/chrome/content/scripts/zoteroupdateifs.js +++ b/chrome/content/scripts/zoteroupdateifs.js @@ -438,7 +438,7 @@ Zotero.UpdateIFs.updateSelectedItem = async function (items) { var ptID = paperName[1]; // publications: tempID 用于得到后面的tempID for (i = 0; i < items.length; i++) { - + var lanItem = items[i].getField('language'); //得到条目语言 if (items[i].isRegularItem() && !items[i].isCollection()) { if (njauCore) items[i].setField( // 设置南农核心 @@ -451,7 +451,6 @@ Zotero.UpdateIFs.updateSelectedItem = async function (items) { - try { var tempID = ptID[items[i].getField('publicationTitle').toUpperCase()] // 得到期刊题目的tempID var ifc = ifs.filter(e => e.tempID == tempID)[0]; //当前期刊的信息 @@ -464,99 +463,174 @@ Zotero.UpdateIFs.updateSelectedItem = async function (items) { var eiivalue = ifc['eii'];// EI收录 var cssci = ifc['cssci']; // CSSCI南大核心 var cscd = ifc['cscd']; // CSCD - var pku = ifc['pku']; // 北大核心 - if (pku === '1') pku = '中文核心期刊'; + var pku = ifc['pku'] === '1' ? '中文核心期刊' : ''; // 北大核心 var zhongguokejihexin = ifc['zhongguokejihexin']; // 科技核心 - } + var eiivalueExtra = ifc['eii'] == 'EI' ? '是' : '否'; // EI收录 用于放入Extra + var cssciExtra = ifc['cssci'] === 'CSSCI' ? '是' : '否'; // CSSCI南大核心 用于放入Extra + var pkuExtra = ifc['pku'] === '1' ? '是' : '否';// 北大核心 用于放入Extra + var zhongguokejihexinExtra = ifc['zhongguokejihexin'] === '中国科技核心期刊' ? '是' : '否'; // 科技核心 用于放入Extra - // 填充到Extra的字符串前辍 - var jcrs = ''; - var casQu1s = '' - var casQu2s = '' - var eiJours = '' - var ifc = ''; - var if5 = ''; - var njuCores = '' - var pkuCores = '' - var cscds = '' - var sciTechs = '' + } // 设置JCR if (jcrQu && sci !== undefined) { items[i].setField(jcrQuField, sci); - jcrs = 'JCR分区: ' + sci + '\n'; + }; //中科院分区分级版 if (casQu1 && sciUp !== undefined) { items[i].setField(casQu1Field, sciUp); - casQu1s = '中科院分区升级版: ' + sciUp + '\n'; + }; //中科院分区基础版 if (casQu2 && sciBase !== undefined) { items[i].setField(casQu2Field, sciBase); - casQu2s = '中科院分区基础版: ' + sciBase + '\n'; + }; //EI if (eiJour && eiivalue !== undefined) { items[i].setField(eiJourField, eiivalue); - eiJours = eiivalue + '\n'; + }; // 设置影响因子 if (sciIf && ifCurrent !== undefined) { items[i].setField(sciIfField, ifCurrent); - ifc = '影响因子: ' + ifCurrent + '\n'; + }; // 设置5年影响因子 if (sciIf5 && if5Year !== undefined) { items[i].setField(sciIf5Field, if5Year); - if5 = '5年影响因子: ' + if5Year + '\n'; + }; //北大中文核心 if (pkuCore && pku !== undefined) { items[i].setField(pkuField, pku); - pkuCores = pku + '\n'; + }; //南大核心 if (njuCore && cssci !== undefined) { items[i].setField(njuField, cssci); - njuCores = cssci + '\n'; + }; //CSCD if (chjCscd && cscd !== undefined) { items[i].setField(cscdField, cscd); - cscds = 'CSCD: ' + cscd + '\n'; + }; //科技核心 if (sciCore && zhongguokejihexin !== undefined) { items[i].setField(sciCoreField, zhongguokejihexin); - sciTechs = zhongguokejihexin + '\n'; + }; + // 填充到Extra的字符串前辍 + var jcrs = ''; + var casQu1s = '' + var casQu2s = '' + var eiJours = '' + var ifc = ''; + var if5 = ''; + var njuCores = '' + var pkuCores = '' + var cscds = '' + var sciTechs = '' + + // 得到Extra + if (sciAllExtra) { + if (sci === undefined) { + sci = '未知'; + }; + jcrs = 'JCR分区: ' + sci + '\n'; + // }; + //中科院分区分级版 + if (sciUp === undefined) { + sciUp = '未知'; + }; + + casQu1s = '中科院分区升级版: ' + sciUp + '\n'; + // }; + //中科院分区基础版 + if (sciBase === undefined) { + sciBase = '未知'; + }; + + casQu2s = '中科院分区基础版: ' + sciBase + '\n'; + // }; + //EI + if (eiivalueExtra === undefined) { + eiivalueExtra = '否'; + }; + eiJours = 'EI: ' + eiivalueExtra + '\n'; + // }; + + // 设置影响因子 + if (ifCurrent === undefined) { + ifCurrent = '未知'; + }; + + ifc = '影响因子: ' + ifCurrent + '\n'; + // }; + // 设置5年影响因子 + if (if5Year === undefined) { + if5Year = '未知'; + }; + if5 = '5年影响因子: ' + if5Year + '\n'; + // }; + //北大中文核心 + if (pkuExtra === undefined) { + pkuExtra = '否'; + }; + + pkuCores = '中文核心期刊/北大核心: ' + pkuExtra + '\n'; + //}; + //南大核心 + if (cssciExtra === undefined) { + cssciExtra = '否'; + }; + + njuCores = 'CSSCI/南大核心: ' + cssciExtra + '\n'; + //}; + //CSCD + //if ( cscd !== undefined) { + if (cscd === undefined) { + cscd = '否' + }; + cscds = 'CSCD: ' + cscd + '\n'; + //}; + //科技核心 + if (zhongguokejihexinExtra === undefined) { + zhongguokejihexinExtra = '否'; + }; + + sciTechs = '中国科技核心期刊: ' + zhongguokejihexinExtra + '\n'; + }; + + var newExtrasEn = jcrs + casQu1s + casQu2s + ifc + if5 + eiJours; // 英文期刊的Extra + var newExtrasCh = eiJours + pkuCores + njuCores + cscds + sciTechs; // 中文期刊的Extra + + var newExtras = lanItem.indexOf('en') !== -1 ? newExtrasEn : newExtrasCh; // 根据期刊语言得到Extra + // return newExtras - var newExtras = jcrs + casQu1s + casQu2s + eiJours + - ifc + if5 + njuCores + pkuCores + cscds + sciTechs; var old = items[i].getField('extra'); // 匹配原来Extra的正则 - var pattExtra = /(JCR分区: Q[1-4])*(中科院分区升级版: .+)*(中科院分区基础版: .+)*(EI)*(影响因子: .+)*(5年影响因子: .+)*(中文核心期刊)*(CSCD: .+)*(中国科技核心期刊)*/g; - + var pattExtraEn = /JCR分区:\s.+\n中科院分区升级版:\s.+\n中科院分区基础版:\s.+\n影响因子:\s.+\n5年影响因子:\s.+\nEI:\s.+\n/g // 匹配英文期刊Extra + var pattExtraCh = /EI:\s.+\n中文核心期刊\/北大核心:\s.+\nCSSCI\/南大核心:\s.+\nCSCD:\s.+\n中国科技核心期刊:\s.+\n/g; // 匹配中文期刊Extra + var pattExtra = lanItem.indexOf('en') !== -1 ? pattExtraEn : pattExtraCh; + //return old.replace(pattExtra, newExtras) try { if (sciAllExtra) { // 如果所有英文期刊信息到其它为真,则全部显示到其它字段 if (old.length == 0) { // 如果内容为空 items[i].setField('extra', newExtras); - } else if (old.search(pattExtra) != -1) { // 如果以前有影响因子则替换 - // 匹配原来Extra内容 - var oldMatch = old.match(pattExtra). - join('\n'). - replace(/\n\n/g, '\n'); + // 匹配原来Extra内容 items[i].setField( 'extra', - old.replace(oldMatch, newExtras)); + old.replace(pattExtra, newExtras)); } else { // 以前没有,且内容不为空 - items[i].setField('extra', newExtras + '\n' + old); + items[i].setField('extra', newExtras + old); } }; } catch (error) { @@ -569,9 +643,6 @@ Zotero.UpdateIFs.updateSelectedItem = async function (items) { numFail++; } - - - } } diff --git a/release.sh b/release.sh index 3aa966a..9fe3504 100644 --- a/release.sh +++ b/release.sh @@ -11,7 +11,7 @@ read -p "Enter new version number: " version perl -pi -e "s/em:version=\"[^\"]*/em:version=\"$version/;" "install.rdf" # rm "install.rdf.bak" -git add "install.rdf" +#git add "install.rdf" ############## @@ -22,10 +22,10 @@ perl -pi -e "s/[^<]*/$version/;" \ -e "s/[^<]*/https:\/\/github.com\/redleafnew\/zotero-updateifse\/releases\/download\/$version\/zotero-updateifs.xpi/;" \ -e "s/[^<]*/https:\/\/github.com\/redleafnew\/zotero-updateifse\/releases\/tag\/$version/;" \ update.rdf -git add "update.rdf" +#git add "update.rdf" # rm "update.rdf.bak" -git commit -m "Release $version" 1>&2 +#git commit -m "Release $version" 1>&2 ############## ## 生成xpi