加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
data.html 3.23 KB
一键复制 编辑 原始数据 按行查看 历史
huaji 提交于 2024-07-22 13:22 . update data.html.
<!DOCTYPE html>
<html>
<head>
<head>
<meta charset="UTF-8">
<link crossorigin="" rel="shortcut icon" type="image/x-icon" href="./logo-200x200.png">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>跳转链接中转</title>
<style data-emotion="css" data-s="">
body {
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
height: 100vh;
margin: 0;
background-image: linear-gradient(rgba(255, 255, 255, 0.09) 74%, rgba(0, 156, 238, 0.3));
}
.mytext {
font-size: 1.5rem;
font-weight: 300;
margin-bottom: 22px;
text-align: center;
}
</style>
</head>
<style>
body,
html {
height: 100%;
margin: 0;
overflow: hidden;
}
iframe {
display: none;
border: none;
}
</style>
</head>
<body>
<iframe id="fullscreen-iframe"
style="position: fixed;top: 0;left: 0;width: 100%;height: 100%;border: none;margin: 0;padding: 0;overflow: hidden;z-index: 999999;display:none"></iframe>
<p class="mytext">加载中...</p>
<script>
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('./sw.js').then((registration) => {
console.log('Service Worker registered with scope:', registration.scope);
}).catch((error) => {
console.error('Service Worker registration failed:', error);
});
}
var url = window.location.href.split(/\?(.+)/)[1];
if (url) {
// 判断最后一个字符是否为等号
if (url.endsWith("=")) {
// 替换最后一个字符为其他字符
url = url.slice(0, -1);
}
url = url.replace(/\./g, '/');
url = "https://aiu.pub/" + url
iframe = document.querySelector("iframe")
iframe.src = url
let receivedMessage = false;
window.addEventListener('message', function (event) {
if (event.data && event.data.title && event.data.url) {
document.title = event.data.title;
console.log("iframe url: " + event.data.url)
receivedMessage = true;
document.getElementsByClassName("mytext")[0].remove()
iframe.style.display = "unset"
}
}, false);
iframe.onload = function () {
setTimeout(function () {
if (receivedMessage == false) {
alert("超时未跳转 请检查链接或网络情况 正在跳转至主页")
window.location.replace(window.location.origin + "/")
}
}, 2000);
};
} else {
window.location.replace(window.location.origin + "/")
}
</script>
</body>
</html>
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化