44 lines
1.4 KiB
JavaScript
44 lines
1.4 KiB
JavaScript
// ==UserScript==
|
|
// @name 导航页切换分类
|
|
// @namespace http://tampermonkey.net/
|
|
// @version 1.0
|
|
// @description 导航页切换分类
|
|
// @author 8ga
|
|
// @match https://nav.jkwlstv.cn/*
|
|
// @grant none
|
|
// @run-at document-idle
|
|
// ==/UserScript==
|
|
|
|
(function () {
|
|
'use strict';
|
|
|
|
window.addEventListener('load', function () {
|
|
setTimeout(init, 1000);
|
|
function init() {
|
|
const search_bar = document.querySelector("#search-bar");
|
|
if (search_bar) {
|
|
search_bar.style.display = 'none';
|
|
}
|
|
const spans = Array.from(document.querySelectorAll(".select-tag"));
|
|
if (spans.length === 0) {
|
|
console.warn("未找到匹配的 span 元素");
|
|
return;
|
|
}
|
|
let currentIndex = 0;
|
|
document.addEventListener('keydown', function (e) {
|
|
if (e.key === 'Tab' || e.keyCode === 9) {
|
|
e.preventDefault(); // 阻止默认 Tab 行为
|
|
|
|
// 更新索引
|
|
currentIndex = (currentIndex + 1) % spans.length;
|
|
|
|
// 触发点击
|
|
const targetSpan = spans[currentIndex];
|
|
if (targetSpan) {
|
|
targetSpan.click();
|
|
}
|
|
}
|
|
});
|
|
}
|
|
});
|
|
})(); |