-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path404.html
211 lines (191 loc) · 6.29 KB
/
404.html
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<link rel="icon" href="./assets/logo.png" />
<title>短连接</title>
<style>
.box {
margin: 5% 5% 0 5%;
padding: 1rem !important;
--dark-grey: #353535;
--middle-grey: #767676;
--lightest-grey: linear-gradient(#fafafa,#ebebeb);
--shadow: 0 5px 15px 0 #00000026;
--shadow-active: 0 5px 5px 0 #00000026;
--border-radius-main: 10px;
--border-radius-icon: 50px;
position: relative;
cursor: default;
color: var(--dark-grey);
opacity: .9;
background: var(--lightest-grey);
border-radius: var(--border-radius-main);
box-shadow: var(--shadow);
transition: .2s ease all;
}
.box:hover{
box-shadow: var(--shadow-active);
}
.titleText {
padding: 0% 2% 0% 2%;
}
.bodyText {
padding: 0% 2% 0% 2%;
font-size: 18px;
}
.timeText {
padding: 0% 2% 0% 2%;
font-size: 16px;
color: rgb(69, 69, 69);
}
.copy-button {
float: inline-end;
padding: 2px 10px;
border: 0;
border-radius: 5px;
background-color: transparent;
color: #a5dc86;
font-weight: normal;
transition: all 0.5s;
-webkit-transition: all 0.5s;
}
.copy-button:hover {
background-color: #a5dc86;
color: white;
box-shadow: 0 0 20px #a5dc8686;
transform: scale(1.1);
}
.copy-button:active {
background-color: #8bb971;
transition: all 0.25s;
-webkit-transition: all 0.25s;
box-shadow: none;
transform: scale(0.98);
}
</style>
<style type="text/css">
body {
font-family: Consolas;
background-image: linear-gradient(90deg, #ffffff, #d8d8d8);
}
</style>
<script>
var PATH_SEGMENTS_TO_SKIP = 0;
function isUrl(url) {
return /^[a-zA-z]+:\/\/[^\s]*$/.test(
url
);
}
function returnHome() {
window.location.replace(
location.protocol +
'//' +
location.hostname +
(location.port ? ':' + location.port : '') +
'/' +
location.pathname.split('/')[PATH_SEGMENTS_TO_SKIP]
);
}
function copyText() {
const textToCopy = document.querySelector(".bodyText");
const copyBtn = document.querySelector(".copy-button");
copyBtn.innerText = '成功';
// 创建一个新的textarea元素,并将要复制的文字设置为其value
const textarea = document.createElement("textarea");
textarea.value = textToCopy.innerText;
// textarea添加到文档中
document.body.appendChild(textarea);
// 选中textarea中的文字
textarea.select();
// 复制选中文字到剪贴板
document.execCommand("copy");
// 移除textarea
document.body.removeChild(textarea);
// 在控制台输出复制成功的消息
console.log("已复制剪贴板:", textarea.value);
setTimeout(()=>{
copyBtn.innerText = '复制';
},500);
}
function redirect() {
var GITEE_ISSUES_LINK = atob('aHR0cHM6Ly9naXRlZS5jb20vYXBpL3Y1L3JlcG9zL3p3OTVjbi9zaG9ydHVybC1kYi9pc3N1ZXMv');
var location = window.location;
homepage =
location.protocol +
'//' +
location.hostname +
(location.port ? ':' + location.port : '') +
'/' +
location.pathname.split('/')[PATH_SEGMENTS_TO_SKIP];
var issueNumber = location.pathname.split('/')[PATH_SEGMENTS_TO_SKIP + 1];
var xhr = new XMLHttpRequest();
xhr.onload = function () {
if (xhr.status === 200) {
var payload = JSON.parse(xhr.response);
var message = payload.message;
var titleText = payload.title;
var bodyText = payload.body;
var timeText = payload.updated_at;
var url = document.createElement('a');
url.setAttribute('href', titleText);
var isInvalidUrl =
message === 'Not Found' || message === 'This issue was deleted' || !titleText || (!isUrl(titleText) && !isUrl(bodyText)) ;
if (isInvalidUrl) {
document.title = titleText;
let divObj = document.createElement('div');
divObj.className = 'box';
let titleObj = document.createElement('h1');
titleObj.className = 'titleText';
titleObj.innerText = titleText;
let copyBtnObj = document.createElement('button');
copyBtnObj.className = 'copy-button';
copyBtnObj.innerText = '复制';
copyBtnObj.addEventListener('click', copyText);
let timeObj = document.createElement('p');
timeObj.className = 'timeText';
let textTime = new Date(timeText);
timeObj.innerText =
textTime.getFullYear() +
'年' +
(textTime.getMonth() + 1) +
'月' +
textTime.getDate() +
'日 ' +
textTime.toLocaleTimeString();
let bodyObj = document.createElement('p');
bodyObj.className = 'bodyText';
bodyObj.innerText = bodyText;
divObj.appendChild(titleObj);
divObj.appendChild(timeObj);
divObj.appendChild(copyBtnObj);
divObj.appendChild(bodyObj);
document.body.appendChild(divObj);
} else {
document.title = '跳转中...';
if(isUrl(titleText)){
location.replace(titleText);
} else {
location.replace(bodyText);
}
}
} else {
console.error(xhr.status+' '+xhr.response);
returnHome();
}
};
xhr.onerror = function () { returnHome(); };
xhr.open('GET', GITEE_ISSUES_LINK + issueNumber);
xhr.send();
}
var homepage;
try {
redirect();
} catch (e) {
console.error(e);
returnHome();
}
</script>
</head>
<body></body>
</html>