-
Notifications
You must be signed in to change notification settings - Fork 0
/
better-interfacelift.user.js
39 lines (33 loc) · 1.24 KB
/
better-interfacelift.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
// ==UserScript==
// @name Better InterfaceLIFT
// @author https://github.com/qligier/
// @namespace qligier
// @version 20190522
// @updateURL https://raw.githubusercontent.com/qligier/web_userscripts/master/better-interfacelift.user.js
// @match https://interfacelift.com/wallpaper/details/*/*
// @grant none
// ==/UserScript==
/**
* This userscript is updated from GitHub.
*/
(function() {
'use strict';
const resolutionSelectTag = document.querySelector('select[name="resolution"]');
const downloadTag = document.querySelector('div[id^="download_"] a');
let maxPixels = 0;
let maxDimension = '';
for (let i=0; i < resolutionSelectTag.options.length; i++) {
const option = resolutionSelectTag[i];
if (option.label.match(/^[0-9]+x[0-9]+/)) {
const dimensions = option.label.split(' ')[0].split('x');
const nbPixels = dimensions[0] * dimensions[1];
if (nbPixels > maxPixels) {
maxPixels = nbPixels;
maxDimension = dimensions[0] + 'x' + dimensions[1];
}
}
}
const oldDownloadURL = downloadTag.getAttribute('href');
const newDownloadURL = oldDownloadURL.replace(/[0-9]+x[0-9]+\.jpg/, maxDimension + '.jpg');
window.location = newDownloadURL;
})();