Skip to content

一分钟搭建影视站,支持Docker等部署方式

Dev (#54)

Zwei40a60b9d9bbb
diff --git a/css/styles.css b/css/styles.css
index 04bc359..b76a043 100644
--- a/css/styles.css
+++ b/css/styles.css
@@ -222,6 +222,20 @@ body {
box-shadow: 0 0 0 2px rgba(0, 204, 255, 0.3);
}
+/* 添加广告过滤开关的CSS */
+#adFilterToggle:checked + .toggle-bg {
+ background-color: var(--primary-color);
+}
+
+#adFilterToggle:checked ~ .toggle-dot {
+ transform: translateX(1.5rem);
+}
+
+#adFilterToggle:focus + .toggle-bg,
+#adFilterToggle:hover + .toggle-bg {
+ box-shadow: 0 0 0 2px rgba(0, 204, 255, 0.3);
+}
+
.toggle-dot {
transition: transform 0.3s ease-in-out;
box-shadow: 0 2px 4px rgba(0,0,0,0.2);
@@ -234,3 +248,7 @@ body {
#yellowFilterToggle:checked ~ .toggle-dot {
box-shadow: 0 2px 4px rgba(0, 204, 255, 0.3);
}
+
+#adFilterToggle:checked ~ .toggle-dot {
+ box-shadow: 0 2px 4px rgba(0, 204, 255, 0.3);
+}
diff --git a/index.html b/index.html
index e436a00..4514f3e 100644
--- a/index.html
+++ b/index.html
@@ -92,6 +92,19 @@
<p class="text-xs text-gray-500 mt-1">过滤分类包含"伦理片"、"色情片"等成人内容</p>
</div>
+ <!-- 添加广告过滤开关 -->
+ <div>
+ <div class="flex items-center justify-between">
+ <label class="text-sm font-medium text-gray-400">分片广告过滤</label>
+ <div class="relative inline-block w-12 align-middle select-none">
+ <input type="checkbox" id="adFilterToggle" class="opacity-0 absolute w-full h-full cursor-pointer z-10">
+ <div class="toggle-bg bg-[#333] w-12 h-6 rounded-full transition-colors duration-300 ease-in-out"></div>
+ <div class="toggle-dot absolute w-5 h-5 bg-white rounded-full top-0.5 left-0.5 transition-transform duration-300 ease-in-out"></div>
+ </div>
+ </div>
+ <p class="text-xs text-gray-500 mt-1">关闭可减少旧版浏览器播放卡顿问题</p>
+ </div>
+
<div class="mt-4">
<p class="text-xs text-gray-500">当前站点代码:
<span id="currentCode" class="text-white"></span>
diff --git a/js/app.js b/js/app.js
index 83997f3..c65a118 100644
--- a/js/app.js
+++ b/js/app.js
@@ -47,6 +47,12 @@ document.addEventListener('DOMContentLoaded', function() {
yellowFilterToggle.checked = localStorage.getItem('yellowFilterEnabled') === 'true';
}
+ // 设置广告过滤开关初始状态
+ const adFilterToggle = document.getElementById('adFilterToggle');
+ if (adFilterToggle) {
+ adFilterToggle.checked = localStorage.getItem(PLAYER_CONFIG.adFilteringStorage) !== 'false'; // 默认为true
+ }
+
// 设置事件监听器
setupEventListeners();
});
@@ -252,6 +258,14 @@ function setupEventListeners() {
localStorage.setItem('yellowFilterEnabled', e.target.checked);
});
}
+
+ // 新增:广告过滤开关事件绑定
+ const adFilterToggle = document.getElementById('adFilterToggle');
+ if (adFilterToggle) {
+ adFilterToggle.addEventListener('change', function(e) {
+ localStorage.setItem(PLAYER_CONFIG.adFilteringStorage, e.target.checked);
+ });
+ }
}
// 重置搜索区域
diff --git a/js/config.js b/js/config.js
index 77f0bcc..799292f 100644
--- a/js/config.js
+++ b/js/config.js
@@ -99,7 +99,9 @@ const PLAYER_CONFIG = {
height: '600',
timeout: 15000, // 播放器加载超时时间
filterAds: true, // 是否启用广告过滤
- autoPlayNext: true // 默认启用自动连播功能
+ autoPlayNext: true, // 默认启用自动连播功能
+ adFilteringEnabled: true, // 默认开启分片广告过滤
+ adFilteringStorage: 'adFilteringEnabled' // 存储广告过滤设置的键名
};
// 增加错误信息本地化
diff --git a/player.html b/player.html
index bf6396b..9895916 100644
--- a/player.html
+++ b/player.html
@@ -245,6 +245,7 @@
let videoHasEnded = false; // 跟踪视频是否已经自然结束
let userClickedPosition = null; // 记录用户点击的位置
let shortcutHintTimeout = null; // 用于控制快捷键提示显示时间
+ let adFilteringEnabled = true; // 默认开启广告过滤
// 页面加载
document.addEventListener('DOMContentLoaded', function() {
@@ -262,6 +263,9 @@
autoplayEnabled = localStorage.getItem('autoplayEnabled') !== 'false'; // 默认为true
document.getElementById('autoplayToggle').checked = autoplayEnabled;
+ // 获取广告过滤设置
+ adFilteringEnabled = localStorage.getItem(PLAYER_CONFIG.adFilteringStorage) !== 'false'; // 默认为true
+
// 监听自动连播开关变化
document.getElementById('autoplayToggle').addEventListener('change', function(e) {
autoplayEnabled = e.target.checked;
@@ -369,7 +373,7 @@
// 配置HLS.js选项
const hlsConfig = {
debug: false,
- loader: CustomHlsJsLoader,
+ loader: adFilteringEnabled ? CustomHlsJsLoader : Hls.DefaultConfig.loader,
enableWorker: true,
lowLatencyMode: false,
backBufferLength: 90,