IEEE TitleAsPDFfileName

save the pdf file using the title as file name.

目前为 2017-02-09 提交的版本。查看 最新版本

// ==UserScript==
// @name         IEEE TitleAsPDFfileName
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  save the pdf file using the title as file name.
// @author       EvanL00
// @match        http://http://ieeexplore.ieee.org/document/*
// @include        http://ieeexplore.ieee.org/*
// @grant        none
// ==/UserScript==

(function() {
 //   'use strict';
     
    // 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 obj = document.createElement("li");
    //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 = /(http:\/\/ieee[^"]+)/;
    var pdfurl = res.match(myRex)[0];
    
    
    
    obj.innerHTML = '<a download='+ '"'+ title.toString() + '"' + ' href=' + pdfurl +'>Save as pdf</a>';
    //loc.appendChild(obj);
    loc.insertBefore(obj, loc.childNodes[0]);
    // create a tag, save as pdf 
    

})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址