Files
chorblack e75f275ef4
Some checks failed
定时更新GitHub源插件 / 自动更新GitHub插件 (push) Has been cancelled
Initial commit
2026-03-07 11:19:25 +08:00

1 line
1.4 KiB
JavaScript

(function(){function closest(el,sel){if(!el)return null;if(el.closest)return el.closest(sel);while(el){if(el.matches&&el.matches(sel))return el;el=el.parentNode}return null}document.addEventListener('click',function(e){var card=closest(e.target,'.lp-mirages-card');if(!card)return;createRipple(e,card);var url=card.getAttribute('data-href');if(url){setTimeout(function(){window.open(url,'_blank','noopener')},90)}});document.addEventListener('keydown',function(e){var card=closest(e.target,'.lp-mirages-card');if(!card)return;if(e.key==='Enter'||e.key===' '){e.preventDefault();var url=card.getAttribute('data-href');if(url)window.open(url,'_blank','noopener')}});function createRipple(event,card){var container=card.querySelector('.lp-mirages-ripple-container');if(!container)return;var circle=document.createElement('span');var diameter=Math.max(card.clientWidth,card.clientHeight);var radius=diameter/2;var rect=card.getBoundingClientRect();var x=(event.clientX?event.clientX:rect.left+rect.width/2)-rect.left;var y=(event.clientY?event.clientY:rect.top+rect.height/2)-rect.top;circle.style.width=circle.style.height=diameter+'px';circle.style.left=(x-radius)+'px';circle.style.top=(y-radius)+'px';circle.className='lp-mirages-ripple';var old=container.getElementsByClassName('lp-mirages-ripple')[0];if(old)old.remove();container.appendChild(circle);setTimeout(function(){circle.remove()},650)}})();