93 lines
3.0 KiB
HTML
93 lines
3.0 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta content="width=device-width,user-scalable=no,initial-scale=1.0,maximum-scale=1.0,minimum-scale=1.0"
|
|
name="viewport">
|
|
<title>冰蛙复制</title>
|
|
<script>
|
|
window.onload = () => {
|
|
const load = document.querySelector('#load')
|
|
load.disabled = true;
|
|
const copy = document.querySelector('#copy')
|
|
copy.disabled = true;
|
|
const cont = document.querySelector('#container p')
|
|
const status = document.querySelector('#status')
|
|
let latest;
|
|
let scriptCont;
|
|
let replace;
|
|
|
|
fetch(`conf.json?${performance.now()}`)
|
|
.then(response => response.json())
|
|
.then(data => {
|
|
latest = data['latest'];
|
|
replace = latest[0]['replace'];
|
|
status.innerHTML = `配置加载完成`;
|
|
cont.innerHTML = `最新版本:${latest[0].ver}`;
|
|
cont.innerHTML += `<br/>文件名:${latest[0].name}`;
|
|
load.disabled = false;
|
|
})
|
|
load.onclick = () => {
|
|
if (!latest) return;
|
|
load.disabled = true;
|
|
status.innerHTML = '正在加载脚本文件';
|
|
fetch(`${latest[0].name}?${performance.now()}`)
|
|
.then(response => response.text())
|
|
.then(text => {
|
|
status.innerHTML = '脚本加载完成';
|
|
scriptCont = replace ? text.replace(replace['with'], replace['to']) : text.replace('https://www.torn.com/*.php*', 'https://www.torn.com/*');
|
|
copy.disabled = false;
|
|
load.disabled = false;
|
|
})
|
|
};
|
|
copy.onclick = () => {
|
|
if (!scriptCont) return;
|
|
copy.disabled = true;
|
|
const clipboardObj = navigator.clipboard;
|
|
if (!clipboardObj) {
|
|
status.innerHTML = '脚本复制出错';
|
|
copy.disabled = false;
|
|
return;
|
|
}
|
|
clipboardObj.writeText(scriptCont);
|
|
status.innerHTML = '脚本复制完成';
|
|
copy.disabled = false;
|
|
};
|
|
};
|
|
</script>
|
|
<style>
|
|
* {
|
|
margin: 0;
|
|
padding: 0;
|
|
border: 0;
|
|
}
|
|
|
|
body {
|
|
max-width: 600px;
|
|
margin: 0 auto;
|
|
}
|
|
|
|
button {
|
|
background-color: black;
|
|
color: white;
|
|
width: 100%;
|
|
padding: 16px;
|
|
font-size: 16px;
|
|
}
|
|
|
|
button[disabled] {
|
|
background-color: gray;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div id="container"><p></p></div>
|
|
<div id="status">正在加载配置文件</div>
|
|
<div>
|
|
<button id="load">加载脚本</button>
|
|
</div>
|
|
<div>
|
|
<button id="copy">复制脚本</button>
|
|
</div>
|
|
</body>
|
|
</html> |