百度找片

【让百度搜索聚合找片功能】,从此找片更为方便!

当前为 2017-01-30 提交的版本,查看 最新版本

// ==UserScript==
// @name         百度找片
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  【让百度搜索聚合找片功能】,从此找片更为方便!
// @author       BackRunner
// @include      *://www.baidu.com*
// @grant        unsafeWindow
// ==/UserScript==

(function() {
	//变量定义
	var content = '';
	var judge = false;
	//主执行区
	bindEvent();
	process_direct();
	
	function process_direct(){
		var search = window.location.search;
		var part = search.split('&');
		for (var i=0;i<part.length;i++){
			if (part[i].indexOf("wd=")!==-1){
				content = part[i].replace('wd=','');
			}
		}
		part = content.split('%20');
		if (part[part.length - 1]==="%E6%89%BE%E7%89%87"){
			content = content.replace('%20%E6%89%BE%E7%89%87','');
			//跳转
			window.location.href = "http://www.zmz2017.com/search/index?keyword="+content;
		}
	}
	//判断并截取搜索内容
	function process_event(){
		content = $('#kw').val();
		var part = content.split(' ');
		console.log(part);
		if (part[part.length-1] === '找片'){
			judge = true;
			content = content.replace(' 找片','');
			//跳转
			window.location.href = "http://www.zmz2017.com/search/index?keyword="+content;
			//reset
			judge=false;
		}
	}
	//绑定百度一下按钮和回车
	function bindEvent(){
		try{
			var btn = document.getElementById('su');
			btn.addEventListener('click',process_event);
		}catch(e){
			console.error(e);
		}
	}
})();