-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdlc.kyocera.surr.user.js
42 lines (39 loc) · 1.19 KB
/
dlc.kyocera.surr.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
// ==UserScript==
// @name dlc_kyoceradocumentsolutions_surrogate
// @description Allows to download Kyocera files without executing their JS.
// @author KOLANICH
// @version 0.1
// @license Unlicense
// @grant none
// @run-at document-idle
// @match https://dlc.kyoceradocumentsolutions.eu/index/service/*
// ==/UserScript==
"use strict";
let eulaLinkRx = /loadEula\('([^']+)'\);/;
let dlBase = "cdn.kyostatics.net";
let aEl = document.createElement("A");
aEl.href = dlBase;
for (let el of document.querySelectorAll("a[onclick]")) {
let fn = el.textContent.trim();
let eulaFunc = el.getAttribute("onclick").trim();
let m = eulaLinkRx.exec(eulaFunc);
if (m) {
aEl.href = m[1];
let pathComps = aEl.pathname.split("/");
let lastComp = pathComps[pathComps.length - 1];
lastComp = lastComp.split(".");
let itemType = lastComp[1];
itemType = itemType.split("-");
itemType[itemType.length - 1] = "File";
itemType = itemType.join("-");
lastComp[1] = itemType;
lastComp[lastComp.length - 1] = "tmp";
lastComp = lastComp.join(".");
pathComps[pathComps.length - 1] = lastComp;
pathComps.push(fn);
el.href = "";
el.pathname = pathComps.join("/");
el.host = dlBase;
el.scheme = "https";
}
}