Files
lmbtfy/js/script.js
2025-06-06 18:52:18 +08:00

5 lines
2.7 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* 修改自https://github.com/mengkunsoft/lmbtfy
*/
if(!window.location.origin){window.location.origin=window.location.protocol+"//"+window.location.hostname+(window.location.port?':'+window.location.port:'')}$.getUrlParam=function(name){var reg=new RegExp("(^|&)"+name+"=([^&]*)(&|$)");var r=window.location.search.substr(1).match(reg);if(r!==null)return unescape(r[2]);return null};$(function(){var $kw=$('#kw'),$searchSubmit=$('#search-submit'),$urlOutput=$('#url-output'),$tips=$('#tips'),$stop=$('#stop'),$arrow=$('#arrow'),$logo=$('img[src="img/baidu_logo.png"]');function isMobileDevice(){return $(window).width()<650}function setDeviceSpecificLogo(){if(isMobileDevice()){$logo.attr('src','img/2.png')}else{$logo.attr('src','img/1.png')}}setDeviceSpecificLogo();$(window).resize(function(){setDeviceSpecificLogo()});var stepTimeout,typeInterval;var query=$.getUrlParam('q');if(!!query){try{query=Base64.decode(query)}catch(e){console.log(e)}}if(!!query){$tips.html('让我来教你正确的打开方式');$stop.fadeIn();stepTimeout=setTimeout(function(){$tips.html('1、找到输入框并选中');$arrow.removeClass('active').show().animate({left:$kw.offset().left+20+'px',top:($kw.offset().top+$kw.outerHeight()/2)+'px'},2000,function(){$tips.html('2、输入你要找的内容');$arrow.addClass('active');stepTimeout=setTimeout(function(){$arrow.fadeOut();var i=0;typeInterval=setInterval(function(){$kw.val(query.substr(0,i));if(++i>query.length){clearInterval(typeInterval);$tips.html('3、点击下“百度一下”按钮');$arrow.removeClass('active').fadeIn().animate({left:$searchSubmit.offset().left+$searchSubmit.width()/2+'px',top:$searchSubmit.offset().top+$searchSubmit.height()/2+'px'},1000,function(){$tips.html('<strong>怎么样,学会了吗?</strong>');$arrow.addClass('active');stepTimeout=setTimeout(function(){window.location='https://www.baidu.com/s?ie=utf-8&wd='+encodeURIComponent(query)},1000)})}},200)},500)})},1000)}$('#search-form').submit(function(){if(!!query)return false;var question=$.trim($kw.val());if(!question){$tips.html('<span style="color: red">搜了个寂寞?</span>');$kw.val('')}else{$tips.html('↓↓↓ 复制下面的链接,教伸手党使用百度');$('#output').fadeIn();$urlOutput.val(window.location.origin+window.location.pathname+'?q='+Base64.encode(question)).focus().select()}return false});var clipboard=new ClipboardJS('[data-clipboard-target]');clipboard.on('success',function(e){$tips.html('<span style="color: #4caf50">复制成功!赶紧把链接甩给伸手党们!</span>')});clipboard.on('error',function(e){$tips.html('<span style="color: red">复制失败,请手动复制...</span>')});$('#preview').click(function(){var link=$urlOutput.val();if(!!link){window.open(link)}})});