-
Notifications
You must be signed in to change notification settings - Fork 1
/
ZJU Download.js
29 lines (28 loc) · 1.18 KB
/
ZJU Download.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// ==UserScript==
// @name ZJU Download
// @namespace http://tampermonkey.net/
// @version 0.1
// @description This script is developed to change the irregular name of file downloaded from ZJU website
// @author Zhang Hongning
// @match *://*.zju.edu.cn/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=www.zju.edu.cn
// @grant none
// ==/UserScript==
(function() {
'use strict';
var dat = document.getElementsByTagName("a");
var allowed_type=["doc","pdf","ppt","xlsx","xls","pptx","docx","psd","xml","csv","txt","mp4","mp3","avi","jpg","png","svg","zip","rar","gz"];
for (var i=0;i<dat.length;i++) {
var tmp = dat[i].textContent.split(".");
var type = tmp[tmp.length-1].toLowerCase();
if (allowed_type.join("<>>>>").indexOf(type)>=0 && type != "") {
dat[i].download = dat[i].textContent;
} else {
tmp = dat[i].href.split(".");
type=tmp[tmp.length-1].toLowerCase();
if (allowed_type.join("<>>>>").indexOf(type)>=0 && type != "") {
dat[i].download = dat[i].textContent+"."+type;
}
}
}
})();