This repository was archived by the owner on Jul 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathscript.js
102 lines (92 loc) · 2.22 KB
/
script.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
const baseURL = "https://api.xecades.xyz/api";
const icons = [
"alipay",
"bilibili",
"codeforces",
"codepen",
"csdn",
"douban",
"email",
"facebook",
"github",
"google",
"jianshu",
"juejin",
"libreoj",
"luogu",
"pixiv",
"qq",
"quora",
"site",
"taobao",
"twitter",
"uva",
"wechat",
"weibo",
"zhihu",
];
function toggleBorder() {
!window.TOG &&
document.body.appendChild(
(window.TOG = document.createElement("style"))
);
(window.CHK = !window.CHK)
? (TOG.innerHTML = `*{box-shadow: 0 0 0 1px cyan}`)
: (TOG.innerHTML = "");
}
var vm = new Vue({
el: "#app",
data: {
icon: icons,
image: baseURL,
params: "",
background: "#1",
text_color: "rgba(51, 51, 51, 1)",
bg_color: "rgba(0, 0, 0, 0)",
date: new Date().getFullYear() + "-12-31",
str: "",
str_placeholder: new Date().getFullYear() + " 年末",
quote: "",
social: [],
},
watch: {
background: (e) => {
vm.setParam("img", e.slice(1));
},
params: (e) => {
vm.image = baseURL + (e ? "?" + e : "");
},
text_color: (e) => {
vm.setParam("color", e.slice(5, e.length - 1).replaceAll(" ", ""));
},
bg_color: (e) => {
vm.setParam("bg", e.slice(5, e.length - 1).replaceAll(" ", ""));
},
date: (e) => {
vm.setParam("date", e);
},
str: (e) => {
vm.setParam("str", e);
},
quote: (e) => {
vm.setParam("quote", e);
},
social: (e) => {
for (var i = 0; i < e.length; i++) vm.setParam(icons[i], e[i]);
},
},
methods: {
setParam(key, value) {
var tmp = new URLSearchParams(vm.params);
if (!value) tmp.delete(key);
else tmp.set(key, value
.replace(/\&/gm, "{%amp%}")
.replace(/\</gm, "{%lt%}")
.replace(/\>/gm, "{%gt%}"));
vm.params = tmp.toString();
},
open() {
window.open(vm.image, "_blank");
}
},
});