-
Notifications
You must be signed in to change notification settings - Fork 4
/
imageDownload.user.js
41 lines (35 loc) · 1.01 KB
/
imageDownload.user.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
30
31
32
33
34
35
36
37
38
39
40
41
// ==UserScript==
// @name imageDownload
// @namespace Yr
// @include http://*.jpg
// @include https://*.jpg
// @include http://*.jpeg
// @include https://*.jpeg
// @include http://*.png
// @include https://*.png
// @include http://*.bmp
// @include https://*.bmp
// @version 1
// @grant none
// ==/UserScript==
// Configs
var autoClose = true;
// Main Code
function closeWindows() {
window.close();
clearInterval(set);
}
(function () {
'use strict';
var filename = location.pathname.substr(location.pathname.lastIndexOf('/') + 1);
var mime = filename.substr(filename.lastIndexOf('.') + 1);
var downloadLink = document.createElement("a");
downloadLink.href = location.href;
downloadLink.download = filename;
downloadLink.type = 'image/' + mime;
document.body.appendChild(downloadLink);
console.log('start download ' + filename);
downloadLink.click();
if (autoClose)
set = setInterval(closeWindows, 1000 * 3);
})();