-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbookmark.js
57 lines (42 loc) · 1.65 KB
/
bookmark.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
javascript:(function() {
let multiGraphiteBaseUrl = "https://multi-graphite.bessarabov.com";
let currentSearchParams = new URLSearchParams(location.search);
let newSearchParams = new URLSearchParams();
if (currentSearchParams.get("title")) {
newSearchParams.set("title", currentSearchParams.get("title"));
} else {
newSearchParams.set("title", "...");
}
newSearchParams.set("json", "[\n {}\n]");
newSearchParams.set("targets", currentSearchParams.getAll("target").join("\n"));
newSearchParams.set("url", location.origin);
var width = currentSearchParams.get("width");
if (width === null) {
newSearchParams.set("width", 300);
} else {
newSearchParams.set("width", width);
}
var height = currentSearchParams.get("height");
if (height === null) {
newSearchParams.set("height", 250);
} else {
newSearchParams.set("height", height);
}
var from = currentSearchParams.get("from");
if (typeof from === 'string' && from.length == 14) {
newSearchParams.set("timeType", "range");
newSearchParams.set("from", from);
newSearchParams.set("until", currentSearchParams.get("until"));
newSearchParams.set("recent", "24h");
} else {
if (from === null) {
from = '-24h';
}
newSearchParams.set("timeType", "recent");
newSearchParams.set("recent", from.substring(1));
newSearchParams.set("from", "00:00_20220101");
newSearchParams.set("until","23:59_20220101");
}
let url = multiGraphiteBaseUrl + "#/?" + newSearchParams.toString();
location.replace(url);
})()