-
Notifications
You must be signed in to change notification settings - Fork 0
/
Save Images from Webpages.user.js
58 lines (49 loc) · 1.51 KB
/
Save Images from Webpages.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// ==UserScript==
// @name Save Images from Webpages
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Store images in memory and download on button click
// @author You
// @match *://*/*
// @grant GM_download
// @grant GM_addStyle
// ==/UserScript==
(function() {
'use strict';
let imageLinks = new Set();
// Monitor for all images on the page and store their URLs
document.querySelectorAll('img').forEach(img => {
const src = img.src;
if (src && src.startsWith('http')) {
imageLinks.add(src);
}
});
// Create a button to trigger the download
const downloadButton = document.createElement('button');
downloadButton.innerText = 'Download Stored Images';
downloadButton.style.position = 'fixed';
downloadButton.style.bottom = '10px';
downloadButton.style.right = '10px';
downloadButton.style.zIndex = '9999';
GM_addStyle(`
button {
padding: 5px 15px;
font-size: 14px;
cursor: pointer;
background-color: #007BFF;
color: #FFF;
border: none;
border-radius: 5px;
transition: background-color 0.3s;
}
button:hover {
background-color: #0056b3;
}
`);
downloadButton.onclick = () => {
imageLinks.forEach(link => {
GM_download(link, link.split('/').pop());
});
};
document.body.appendChild(downloadButton);
})();