// ==UserScript== // @name Hanime按钮添加 // @namespace https://www.tampermonkey.net/ // @version 1.2 // @description 添加镜像网站的Hanime缺失的搜索框和评论浮动切换按钮。 // @author Grok && Aloazny // @match https://www.hanime1-me.icu/* // @match https://www.hanime365.top/* // @match https://www.hanime365.icu/* // @match https://hanime*.*/* // @match https://www.hanime*.*/* // @match https://*.hanime*.*/* // @grant none // @license MIT // @run-at document-start // ==/UserScript== (function() { 'use strict'; function createCustomSearchFloatButton() { const style = document.createElement('style'); style.textContent = `#search-form,#search-form input#nav-query,#search-form .search-nav-bar,#search-form img[style*="position: absolute"][style*="left: 10px"],form#search-form{display:none!important} #custom-float-search-btn{position:fixed;bottom:85px;right:28px;width:62px;height:62px;background:rgba(30,30,40,.68);backdrop-filter:blur(12px);-webkit-backdrop-filter:blur(12px);border-radius:50%;border:1px solid rgba(100,100,120,.35);box-shadow:0 5px 18px rgba(0,0,0,.5);display:flex;align-items:center;justify-content:center;z-index:2147483646;cursor:pointer;transition:all .25s ease} #custom-float-search-btn:hover{transform:scale(1.12);background:rgba(40,40,55,.78)} #custom-float-search-btn:active{transform:scale(.92)} .search-widget-icon{width:34px!important;height:34px!important} #custom-search-modal{position:fixed;inset:0;background:rgba(0,0,0,.8);backdrop-filter:blur(16px);-webkit-backdrop-filter:blur(16px);display:none;align-items:center;justify-content:center;z-index:2147483647} #custom-search-modal.show{display:flex!important} #custom-search-dialog{background:#181818;border:1px solid #333;border-radius:12px;padding:28px 32px;width:90%;max-width:440px;box-shadow:0 15px 45px rgba(0,0,0,.7);animation:popIn .5s cubic-bezier(.34,1.56,.64,1)} @keyframes popIn{0%{opacity:0;transform:scale(.75) translateY(30px)}55%{opacity:1;transform:scale(1.08) translateY(-8px)}80%{transform:scale(.96) translateY(4px)}100%{transform:scale(1) translateY(0)}} .search-input-wrapper{position:relative;width:100%} #custom-search-input{width:100%;height:52px;background:#222;border:1px solid #444;border-radius:8px;color:#ddd;font-size:16px;padding:0 56px 0 16px;outline:none;box-sizing:border-box} #custom-search-input:focus{border-color:#555;box-shadow:0 0 0 2px rgba(80,80,100,.4)} #custom-search-clear{position:absolute;right:8px;top:50%;transform:translateY(-50%);width:38px;height:38px;background:#333;border-radius:50%;color:#bbb;font-size:18px;font-weight:700;display:flex;align-items:center;justify-content:center;cursor:pointer;transition:all .15s} #custom-search-clear:hover{background:#444;color:#eee} #custom-search-clear:active{transform:translateY(-50%) scale(.92)} #tablinks-wrapper{display:none!important} #floating-tab-switch{position:fixed;bottom:170px;right:20px;background:rgba(30,30,40,.85);backdrop-filter:blur(12px);-webkit-backdrop-filter:blur(12px);border-radius:25px;border:1px solid rgba(100,100,120,.35);box-shadow:0 5px 18px rgba(0,0,0,.5);display:flex;align-items:center;justify-content:center;z-index:2147483645;cursor:pointer;transition:all .25s ease;padding:8px 16px;color:#ddd;font-size:14px;font-weight:bold} #floating-tab-switch:hover{background:rgba(40,40,55,.95);transform:scale(1.05)} #floating-tab-switch:active{transform:scale(.95)}`; document.head.appendChild(style); const floatBtn = document.createElement('div'); floatBtn.id = 'custom-float-search-btn'; floatBtn.innerHTML = ``; document.body.appendChild(floatBtn); const modal = document.createElement('div'); modal.id = 'custom-search-modal'; const dialog = document.createElement('div'); dialog.id = 'custom-search-dialog'; const wrapper = document.createElement('div'); wrapper.className = 'search-input-wrapper'; const input = document.createElement('input'); input.id = 'custom-search-input'; input.type = 'text'; input.placeholder = '输入关键词搜索'; input.autofocus = true; const clearBtn = document.createElement('div'); clearBtn.id = 'custom-search-clear'; clearBtn.textContent = '×'; wrapper.appendChild(input); wrapper.appendChild(clearBtn); dialog.appendChild(wrapper); modal.appendChild(dialog); document.body.appendChild(modal); floatBtn.onclick = () => { modal.classList.add('show'); input.focus(); input.select(); }; clearBtn.onclick = () => { if (input.value.trim()) { input.value = ''; input.focus(); } else { modal.classList.remove('show'); } }; modal.onclick = e => { if (e.target === modal) modal.classList.remove('show'); }; input.addEventListener('keydown', e => { if (e.key === 'Enter') { const q = input.value.trim(); if (q) window.location.href = `/search?query=${encodeURIComponent(q)}`; modal.classList.remove('show'); } }); } function createFloatingTabSwitch() { const checkTabButtons = () => { const relatedBtn = document.querySelector('#defaultOpen'); const commentBtn = document.querySelector('#comment-tablink'); if (!relatedBtn || !commentBtn) return false; const wrapper = document.querySelector('#tablinks-wrapper'); if (wrapper) { wrapper.style.display = 'none'; } let isRelatedActive = relatedBtn.classList.contains('active'); const commentCount = document.querySelector('#tab-comments-count')?.textContent || ''; const floatingTab = document.getElementById('floating-tab-switch') || document.createElement('div'); floatingTab.id = 'floating-tab-switch'; floatingTab.textContent = isRelatedActive ? `评论${commentCount ? ` (${commentCount})` : ''}` : '相关影片'; floatingTab.onclick = () => { if (isRelatedActive) { commentBtn.click(); floatingTab.textContent = '相关影片'; } else { relatedBtn.click(); floatingTab.textContent = `评论${commentCount ? ` (${commentCount})` : ''}`; } isRelatedActive = !isRelatedActive; }; if (!document.getElementById('floating-tab-switch')) { document.body.appendChild(floatingTab); } return true; }; const observer = new MutationObserver(() => { if (checkTabButtons()) { observer.disconnect(); } }); if (!checkTabButtons()) { observer.observe(document.body, { childList: true, subtree: true }); setTimeout(() => { if (!document.getElementById('floating-tab-switch')) { checkTabButtons(); } }, 2000); } } function removeAdsAndScripts() { document.querySelectorAll('script[async="true"][src]').forEach(script => { script.remove(); }); document.querySelectorAll('script[src*="view_booster"]').forEach(script => { script.remove(); }); document.querySelectorAll('script:not([src])').forEach(script => { const content = script.textContent || ''; if (content.includes('createFixedBottomBanner') || content.includes('addImageAd') || content.includes('loadNewPopupAd')) { script.remove(); } }); document.querySelectorAll('#btimgid1, #btmad1, #more-related-ad, iframe[src*="/HereByAD"], iframe[src*="/herebyad"], div.hidden-md.hidden-lg[style*="display: inline-block; overflow-y: hidden;"]').forEach(el => { el.remove(); }); const fixedBanners = document.querySelectorAll('div'); fixedBanners.forEach(el => { const style = el.style.cssText || ''; if (style.includes('fixed') && style.includes('bottom:0') && (el.textContent.includes('防失联') || el.textContent.includes('安装APP'))) { el.remove(); } }); const adFunctions = ['createFixedBottomBannerWithClose', 'addImageAd', 'loadNewPopupAd']; adFunctions.forEach(fnName => { try { window[fnName] = function() {}; } catch (e) {} }); const observer = new MutationObserver((mutations) => { mutations.forEach((mutation) => { mutation.addedNodes.forEach((node) => { if (node.nodeType === 1) { if (node.tagName === 'SCRIPT') { const src = node.src || ''; const content = node.textContent || ''; if (node.hasAttribute('async') || src.includes('view_booster') || content.includes('createFixedBottomBanner') || content.includes('addImageAd')) { node.remove(); } } } }); }); }); observer.observe(document.documentElement, { childList: true, subtree: true }); } function init() { removeAdsAndScripts(); createCustomSearchFloatButton(); createFloatingTabSwitch(); } document.addEventListener('DOMContentLoaded', init); if (document.readyState !== 'loading') { init(); } })();