IEEE TitleAsPDFfileName

在下载IEEE的论文将文件名命名为题目,而不是一串数字 save the pdf file using the title as file name.

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         IEEE TitleAsPDFfileName
// @namespace    http://tampermonkey.net/
// @version      3.0.3
// @description  在下载IEEE的论文将文件名命名为题目,而不是一串数字 save the pdf file using the title as file name.
// @author       EvanL00
// @include      https://ieeexplore.ieee.org/*
// @grant        none
// ==/UserScript==

function saveAsPdf() {
    // find the title
    var title = document.getElementsByClassName("document-title")[0].innerText;
    //find where to put the tag
    var loc = document.getElementsByClassName("doc-actions stats-document-lh-actions")[0];
    var downloadPdf = document.getElementsByClassName("doc-actions-link stats-document-lh-action-downloadPdf_2 ng-scope");
    //get the pdf url
    var getUrlHttp = new XMLHttpRequest();
    var lists = loc.getElementsByTagName("li");
    var urlli = lists[0];
    var atag = urlli.getElementsByTagName('a')[0];
    var suffix = atag.getAttribute("href");
    var url = suffix.toString();
    getUrlHttp.open('GET', url, false);
    getUrlHttp.send(null);
    var res = getUrlHttp.responseText;
    var myRex = /(https:\/\/ieee[^"]+)/;
    var pdfurl = res.match(myRex)[0];
    var fileName = title.toString().replace(':', '--') + '.pdf';
    downloadPdf[0].setAttribute('href',pdfurl);
    downloadPdf[0].setAttribute('download', fileName);
}
window.onload = saveAsPdf;