12. September 2023
body {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
padding: 20px;
}
.panel {
width: 400px;
padding: 20px;
background-color: #f0f0f0;
border-radius: 4px;
box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
}
.panel form {
margin-bottom: 20px;
}
.panel label {
display: block;
font-weight: bold;
margin-bottom: 10px;
}
.panel input[type=text] {
padding: 5px;
width: 100%;
}
.panel button {
padding: 5px 15px;
background-color: #4CAF50;
color: white;
border: none;
cursor: pointer;
}
.panel button:hover {
background-color: #45a049;
}
.panel textarea {
width: 100%;
height: 200px;
padding: 10px;
border: 1px solid #ccc;
overflow-y: scroll;
}
.panel input[type=radio] {
margin-right: 5px;
}
.panel label.mode-label {
margin-bottom: 5px;
}
.panel #clearButton {
margin-top: 10px;
}
function processLink(event) {
event.preventDefault();
var inputLink = document.getElementById("inputLink");
var outputBox = document.getElementById("output");
outputBox.value = ""; // 清空之前的结果
var mode = document.querySelector('input[name="mode"]:checked').value;
var prefix = "https://drive.google.com/uc?export=download&id=";
if (mode === "single") {
var id = inputLink.value.match(/[-\w]{25,}/);
if (id !== null) {
var result = prefix + id[0];
outputBox.value += result + "\n";
} else {
outputBox.value = "请输入有效的链接!";
}
} else if (mode === "multi") {
var links = inputLink.value.split("\n");
for (var i = 0; i < links.length; i++) {
var id = links[i].match(/[-\w]{25,}/);
if (id !== null) {
var result = prefix + id[0];
outputBox.value += result + "\n";
} else {
outputBox.value += "无效链接:" + links[i] + "\n";
}
}
}
}
function copyToClipboard() {
var outputBox = document.getElementById("output");
outputBox.select();
outputBox.setSelectionRange(0, 99999); // 兼容所有浏览器
document.execCommand("copy");
}
function clearForm() {
var inputLink = document.getElementById("inputLink");
var outputBox = document.getElementById("output");
inputLink.value = "";
outputBox.value = "";
}