万方数据 根据论文信息整理出引用字符串

万方数据 根据论文信息整理出引用字符串(暂时只有期刊),未解决页数的读取,需要自行去论文利查找填写。

当前为 2020-06-20 提交的版本,查看 最新版本

// ==UserScript==
// @name         万方数据 根据论文信息整理出引用字符串
// @namespace    http://elib.ecnudec.com/
// @version      0.1
// @description  万方数据 根据论文信息整理出引用字符串(暂时只有期刊),未解决页数的读取,需要自行去论文利查找填写。
// @author       Shining77
// @match        *://elib.ecnudec.com/*
// @include      *://elib.ecnudec.com/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // Your code here...
    // 许光建, 魏义方, 戴李元,等. 中国城市住房价格变动影响因素分析[J]. 经济理论与经济管理, 2010(8):5-14.
    // 作者.题(篇)名[J].刊名.出版年(卷号):起止页.,
    let authors = '';
    let title = '';
    let type = '';
    let journal = '';
    let year = '';
    let number = '';
    let startPage = 0;
    let endPage = 0;

    let authorsList = [];
    document.querySelectorAll('.author_td a').forEach(author => authorsList.push(author.innerText));
    if (authorsList.length > 3) {
        authors = `${authorsList.slice(0,3).join(', ')}等`;
    } else {
        authors = `${authorsList.slice(0,3).join(', ')}`;
    }
    console.log(authors);
    title = document.getElementById('title0').innerText;
    type = 'J';
    journal = document.querySelectorAll('tr')[3].querySelector('a').innerText;
    let yearAndNumber = document.querySelectorAll('tr')[5].querySelector('a').innerText.split(', ');

    let qouteString = `${authors}. ${title}[${type}]. ${journal}, ${yearAndNumber}:${startPage}-${endPage}.`;
    let qouteNode = document.createElement('div');
    qouteNode.innerText = qouteString;
    qouteNode.setAttribute("style", "margin: 20px 0;background-color: yellow");

    let targetElement = document.querySelectorAll('.abstract_dl')[0];
    targetElement.parentNode.insertBefore(qouteNode, targetElement);
})();