// ==UserScript==
// @name HuggingFace镜像链接提取器
// @namespace http://tampermonkey.net/
// @version 1.1
// @description 在HuggingFace页面提取下载链接,同时显示原始链接和hf-mirror.com镜像链接。v1.1: 清理文件名、识别主要文件、优化布局
// @author AI Assistant
// @match https://huggingface.co/*
// @match https://hf-mirror.com/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=huggingface.co
// @grant none
// @downloadURL none
// ==/UserScript==
(function() {
'use strict';
// 创建样式
const style = document.createElement('style');
style.textContent = `
.hf-extractor-btn {
position: fixed;
top: 20px;
left: 20px;
width: 60px;
height: 60px;
background: linear-gradient(45deg, #ff6b6b, #feca57);
color: white;
border: none;
border-radius: 50%;
cursor: pointer;
font-size: 12px;
font-weight: bold;
z-index: 10000;
box-shadow: 0 4px 15px rgba(0,0,0,0.3);
transition: all 0.3s ease;
}
.hf-extractor-btn:hover {
transform: scale(1.1);
box-shadow: 0 6px 20px rgba(0,0,0,0.4);
}
.hf-modal {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0,0,0,0.5);
z-index: 9999;
display: none;
justify-content: center;
align-items: center;
}
.hf-modal-content {
background: white;
border-radius: 15px;
padding: 25px;
max-width: 90vw;
max-height: 90vh;
overflow: auto;
box-shadow: 0 10px 30px rgba(0,0,0,0.3);
min-width: 700px;
}
.hf-header {
text-align: center;
margin-bottom: 20px;
color: #333;
border-bottom: 2px solid #eee;
padding-bottom: 15px;
}
.hf-stats {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
padding: 15px;
border-radius: 10px;
text-align: center;
margin-bottom: 20px;
font-weight: bold;
}
.hf-buttons {
display: flex;
gap: 10px;
margin-bottom: 20px;
flex-wrap: wrap;
}
.hf-btn {
padding: 10px 15px;
border: none;
border-radius: 8px;
cursor: pointer;
font-weight: bold;
transition: all 0.3s ease;
flex: 1;
min-width: 120px;
}
.hf-btn:hover {
transform: translateY(-2px);
box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}
.hf-btn-close { background: #e74c3c; color: white; }
.hf-btn-copy-first { background: #3498db; color: white; }
.hf-btn-copy-all-orig { background: #27ae60; color: white; }
.hf-btn-copy-all-mirror { background: #f39c12; color: white; }
.hf-link-item {
background: #f8f9fa;
border: 1px solid #dee2e6;
border-radius: 10px;
padding: 12px;
margin-bottom: 12px;
transition: all 0.3s ease;
}
.hf-link-item.main-file {
border: 2px solid #ff6b6b;
background: linear-gradient(135deg, #fff5f5 0%, #ffe8e8 100%);
}
.hf-link-item:hover {
box-shadow: 0 4px 15px rgba(0,0,0,0.1);
transform: translateY(-2px);
}
.hf-file-name {
font-weight: bold;
color: #2c3e50;
margin-bottom: 6px;
font-size: 16px;
display: flex;
align-items: center;
gap: 8px;
}
.hf-main-file {
background: linear-gradient(45deg, #ff6b6b, #feca57);
color: white;
padding: 2px 8px;
border-radius: 12px;
font-size: 11px;
font-weight: bold;
}
.hf-link-row {
display: flex;
align-items: center;
margin-bottom: 4px;
padding: 6px;
background: white;
border-radius: 5px;
}
.hf-link-label {
font-weight: bold;
min-width: 60px;
margin-right: 8px;
}
.hf-link-url {
flex: 1;
font-family: monospace;
font-size: 12px;
word-break: break-all;
margin-right: 8px;
}
.hf-copy-btn {
padding: 5px 10px;
border: none;
border-radius: 5px;
cursor: pointer;
font-size: 11px;
font-weight: bold;
transition: all 0.2s ease;
}
.hf-copy-orig { background: #3498db; color: white; }
.hf-copy-mirror { background: #f39c12; color: white; }
.hf-copy-btn:hover { opacity: 0.8; }
.hf-more-info {
text-align: center;
padding: 15px;
color: #7f8c8d;
font-style: italic;
background: #ecf0f1;
border-radius: 8px;
}
`;
document.head.appendChild(style);
// 创建提取按钮
const extractBtn = document.createElement('button');
extractBtn.className = 'hf-extractor-btn';
extractBtn.innerHTML = '🔗
提取';
document.body.appendChild(extractBtn);
// 创建模态框
const modal = document.createElement('div');
modal.className = 'hf-modal';
modal.innerHTML = `