diff --git a/CiNii Research.js b/CiNii Research.js new file mode 100644 index 0000000000..d7321cd264 --- /dev/null +++ b/CiNii Research.js @@ -0,0 +1,168 @@ +{ + "translatorID": "46291dc3-5cbd-47b7-8af4-d009078186f6", + "label": "CiNii Research", + "creator": "Michael Berkowitz, Mitsuo Yoshida and Satoshi Ando", + "target": "^https?://cir\\.nii\\.ac\\.jp/", + "minVersion": "1.0.0b4.r5", + "maxVersion": "", + "priority": 100, + "inRepository": true, + "translatorType": 4, + "browserSupport": "gcsibv", + "lastUpdated": "2024-09-26 14:22:20" +} + +/* + ***** BEGIN LICENSE BLOCK ***** + + Copyright © 2024 Michael Berkowitz, Mitsuo Yoshida and Satoshi Ando + + This file is part of Zotero. + + Zotero is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Zotero is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with Zotero. If not, see . + + ***** END LICENSE BLOCK ***** +*/ + +function detectWeb(doc, url) { + if (url.includes("/crid/")) { + return "journalArticle"; + } + else if (doc.evaluate('//a[contains(@href, "/crid/")]', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { + return "multiple"; + } + return false; +} + +function doWeb(doc, url) { + var arts = []; + if (detectWeb(doc, url) == "multiple") { + var items = {}; + var links = doc.evaluate('//a[contains(@href, "/crid/")]', doc, null, XPathResult.ANY_TYPE, null); + var link; + while ((link = links.iterateNext())) { + items[link.href] = Zotero.Utilities.trimInternal(link.textContent); + } + Zotero.selectItems(items, function (items) { + if (!items) { + return; + } + for (var i in items) { + arts.push(i); + } + Zotero.Utilities.processDocuments(arts, scrape); + }); + } + else { + scrape(doc, url); + } +} + +function scrape(doc, _url) { + var newurl = doc.location.href; + var biblink = ZU.xpathText(doc, '//li/div/a[contains(text(), "BibTeX")]/@href'); + //Z.debug(biblink) + var tags = []; + if (doc.evaluate('//a[@rel="tag"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { + var kws = doc.evaluate('//a[@rel="tag"]', doc, null, XPathResult.ANY_TYPE, null); + var kw; + while ((kw = kws.iterateNext())) { + tags.push(Zotero.Utilities.trimInternal(kw.textContent)); + } + } + //var abstractPath = '//div[@class="abstract"]/p[@class="entry-content"]'; + var abstractPath = '//div[contains(@class, "abstract")]/p[contains(@class, "entry-content")]'; + var abstractNote; + if (doc.evaluate(abstractPath, doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { + abstractNote = doc.evaluate(abstractPath, doc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent; + } + Zotero.Utilities.HTTP.doGet(biblink, function (text) { + var trans = Zotero.loadTranslator("import"); + trans.setTranslator("9cb70025-a888-4a29-a210-93ec52da40d4"); + trans.setString(text); + trans.setHandler("itemDone", function (obj, item) { + item.url = newurl; + item.attachments = [{ url: item.url, title: item.title + " Snapshot", mimeType: "text/html" }]; + item.tags = tags; + item.abstractNote = abstractNote; + if (item.ISSN) { + item.ISSN = ZU.cleanISSN(item.ISSN); + } + item.complete(); + }); + trans.translate(); + }); +} + +/** BEGIN TEST CASES **/ +var testCases = [ + { + "type": "web", + "url": "https://cir.nii.ac.jp/all?q=test&range=0&count=20&sortorder=1&type=0", + "items": "multiple" + }, + { + "type": "web", + "url": "https://cir.nii.ac.jp/crid/1390001204062164736", + "items": [ + { + "itemType": "journalArticle", + "title": "観測用既存鉄骨造モデル構造物を用いたオンライン応答実験", + "creators": [ + { + "firstName": "謙一", + "lastName": "大井", + "creatorType": "author" + }, + { + "firstName": "與助", + "lastName": "嶋脇", + "creatorType": "author" + }, + { + "firstName": "拓海", + "lastName": "伊藤", + "creatorType": "author" + }, + { + "firstName": "玉順", + "lastName": "李", + "creatorType": "author" + } + ], + "date": "2002", + "DOI": "10.11188/seisankenkyu.54.384", + "ISSN": "1881-2058", + "abstractNote": "特集 ERS(耐震構造学)", + "issue": "6", + "itemID": "1390001204062164736", + "libraryCatalog": "CiNii Research", + "pages": "384-387", + "publicationTitle": "生産研究", + "url": "https://cir.nii.ac.jp/crid/1390001204062164736", + "volume": "54", + "attachments": [ + { + "title": "観測用既存鉄骨造モデル構造物を用いたオンライン応答実験 Snapshot", + "mimeType": "text/html" + } + ], + "tags": [], + "notes": [], + "seeAlso": [] + } + ] + } +] +/** END TEST CASES **/ diff --git a/CiNii.js b/CiNii.js deleted file mode 100644 index 4e0ba9eb10..0000000000 --- a/CiNii.js +++ /dev/null @@ -1,136 +0,0 @@ -{ - "translatorID": "46291dc3-5cbd-47b7-8af4-d009078186f6", - "label": "CiNii", - "creator": "Michael Berkowitz and Mitsuo Yoshida", - "target": "^https?://ci\\.nii\\.ac\\.jp/", - "minVersion": "1.0.0b4.r5", - "maxVersion": "", - "priority": 100, - "inRepository": true, - "translatorType": 4, - "browserSupport": "gcsibv", - "lastUpdated": "2012-11-24 13:12:41" -} - -function detectWeb(doc, url) { - if (url.match(/naid/)) { - return "journalArticle"; - } else if (doc.evaluate('//a[contains(@href, "/naid/")]', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - return "multiple"; - } -} - -function doWeb(doc, url) { - var arts = new Array(); - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - var links = doc.evaluate('//a[contains(@href, "/naid/")]', doc, null, XPathResult.ANY_TYPE, null); - var link; - while (link = links.iterateNext()) { - items[link.href] = Zotero.Utilities.trimInternal(link.textContent); - } - Zotero.selectItems(items, function (items) { - if (!items) { - return true; - } - for (var i in items) { - arts.push(i); - } - Zotero.Utilities.processDocuments(arts, scrape, function () { - Zotero.done(); - }); - Zotero.wait(); - }); - } else { - scrape(doc, url) - } -} -function scrape(doc, url){ - var newurl = doc.location.href; - var biblink = ZU.xpathText(doc, '//li/div/a[contains(text(), "BibTeX")]/@href'); - //Z.debug(biblink) - var tags = new Array(); - if (doc.evaluate('//a[@rel="tag"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - var kws = doc.evaluate('//a[@rel="tag"]', doc, null, XPathResult.ANY_TYPE, null); - var kw; - while (kw = kws.iterateNext()) { - tags.push(Zotero.Utilities.trimInternal(kw.textContent)); - } - } - var abstractNote; - if (doc.evaluate('//div[@class="abstract"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - abstractNote = doc.evaluate('//div[@class="abstract"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent; - } - Zotero.Utilities.HTTP.doGet(biblink, function(text) { - var trans = Zotero.loadTranslator("import"); - trans.setTranslator("9cb70025-a888-4a29-a210-93ec52da40d4"); - trans.setString(text); - trans.setHandler("itemDone", function(obj, item) { - item.url = newurl; - item.attachments = [{url:item.url, title:item.title + " Snapshot", mimeType:"text/html"}]; - item.tags = tags; - item.abstractNote = abstractNote; - item.complete(); - }); - trans.translate(); - }); - }/** BEGIN TEST CASES **/ -var testCases = [ - { - "type": "web", - "url": "http://ci.nii.ac.jp/search?q=test&range=0&count=20&sortorder=1&type=0", - "items": "multiple" - }, - { - "type": "web", - "url": "http://ci.nii.ac.jp/naid/110000244188/ja/", - "items": [ - { - "itemType": "journalArticle", - "title": "<研究速報>観測用既存鉄骨造モデル構造物を用いたオンライン応答実験=Pseudo-dynamic tests on existing steel model structure for seismic monitoring", - "creators": [ - { - "firstName": "謙一=Kenichi Ohi", - "lastName": "大井", - "creatorType": "author" - }, - { - "firstName": "輿助=Yosuke Shimawaki", - "lastName": "嶋脇", - "creatorType": "author" - }, - { - "firstName": "拓海=Takumi Ito", - "lastName": "伊藤", - "creatorType": "author" - }, - { - "firstName": "Li", - "lastName": "Yushun", - "creatorType": "author" - } - ], - "date": "November 2002", - "DOI": "10.11188/seisankenkyu.54.384", - "ISSN": "0037105X", - "issue": "6", - "itemID": "110000244188", - "libraryCatalog": "CiNii", - "pages": "384-387", - "publicationTitle": "生産研究", - "url": "http://ci.nii.ac.jp/naid/110000244188/ja/", - "volume": "54", - "attachments": [ - { - "title": "<研究速報>観測用既存鉄骨造モデル構造物を用いたオンライン応答実験=Pseudo-dynamic tests on existing steel model structure for seismic monitoring Snapshot", - "mimeType": "text/html" - } - ], - "tags": [], - "notes": [], - "seeAlso": [] - } - ] - } -] -/** END TEST CASES **/ \ No newline at end of file