Loading...
Loading...
Export paper from CNKI and push to Zotero, or save as RIS file. Use when user wants to save a paper to Zotero or export citation data.
npx skill4agent add cookjohn/cnki-skills cnki-exportzoterorisgb| Context | Mode | Tool calls |
|---|---|---|
| On a paper detail page | Single export (Step 1A) | 1 evaluate + 1 bash = 2 |
| On a search results page, save all/selected | Batch export (Step 1B) | 1 evaluate + 1 bash = 2 |
| Need to search then save | Use cnki-search first, then batch export | 4 total |
mcp__chrome-devtools__evaluate_scriptasync () => {
const url = document.querySelector('#export-url')?.value;
const params = document.querySelector('#export-id')?.value;
const uniplatform = new URLSearchParams(window.location.search).get('uniplatform') || 'NZKPT';
if (!url || !params) return { error: 'Not on a paper detail page' };
const resp = await fetch(url, {
method: 'POST',
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
body: new URLSearchParams({ filename: params, displaymode: 'GBTREFER,elearning,EndNote', uniplatform })
});
const data = await resp.json();
if (data.code !== 1) return { error: data.msg };
const result = {};
for (const item of data.data) {
result[item.mode] = item.value[0];
}
const body = document.body.innerText;
result.pageUrl = window.location.href;
result.issn = body.match(/ISSN[::]\s*(\S+)/)?.[1] || '';
result.dbcode = document.querySelector('#paramdbcode')?.value || '';
result.dbname = document.querySelector('#paramdbname')?.value || '';
result.filename = document.querySelector('#paramfilename')?.value || '';
return result;
}input.cbItemvalue#export-idmcp__chrome-devtools__evaluate_scriptasync () => {
const API_URL = 'https://kns.cnki.net/dm8/API/GetExport';
// Get all checkbox values (= export encrypted IDs)
const checkboxes = document.querySelectorAll('.result-table-list tbody input.cbItem');
const rows = document.querySelectorAll('.result-table-list tbody tr');
if (checkboxes.length === 0) return { error: 'No results on page' };
const allPapers = [];
for (let i = 0; i < checkboxes.length; i++) {
const exportId = checkboxes[i].value;
const paperUrl = rows[i]?.querySelector('td.name a.fz14')?.href || '';
const resp = await fetch(API_URL, {
method: 'POST',
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
body: new URLSearchParams({ filename: exportId, displaymode: 'GBTREFER,elearning,EndNote', uniplatform: 'NZKPT' })
});
const data = await resp.json();
if (data.code === 1) {
const result = {};
for (const item of data.data) { result[item.mode] = item.value[0]; }
result.pageUrl = paperUrl;
// Extract ISSN from ENDNOTE %@ field
const issnMatch = result.ENDNOTE?.match(/%@\s*([^\s<]+)/);
result.issn = issnMatch ? issnMatch[1] : '';
result.dbcode = 'CJFQ';
result.dbname = '';
result.filename = '';
allPapers.push(result);
}
}
return allPapers; // JSON array, directly writable to file for Python script
}// Replace the for loop condition:
const indices = [0, 2, 4]; // 0-indexed: papers #1, #3, #5
for (let i = 0; i < checkboxes.length; i++) {
if (!indices.includes(i)) continue;
// ... rest same
}python "e:/cnki/.claude/skills/cnki-export/scripts/push_to_zotero.py" /tmp/papers.json{}[{}, {}, ...]POST http://127.0.0.1:23119/connector/saveItems已将论文添加到 Zotero:
标题: {title}
作者: {authors}
期刊: {journal}
GB/T 7714 引用: {gbt_citation}已批量添加 {count} 篇论文到 Zotero:
1. {title1} ({journal1})
2. {title2} ({journal2})
...| Parameter | Value | Source |
|---|---|---|
| API URL | | Fixed, works from any page |
| filename | Encrypted ID | Detail page: |
| displaymode | | Comma-separated modes |
| uniplatform | | Required |
| Element | Selector | Page |
|---|---|---|
| Export URL | | Detail page only |
| Export ID | | Detail page only |
| Checkbox (= export ID) | | Search results page |
| Result rows | | Search results page |
| Title link | | Search results page |
POST http://127.0.0.1:23119/connector/saveItems
Content-Type: application/json
X-Zotero-Connector-API-Version: 3python "e:/cnki/.claude/skills/cnki-export/scripts/push_to_zotero.py" --listlocalhost:23119namecreatorType: "author"filename#export-idinput.cbItem#paramfilename