百度云插件+APIKey

在百度云网盘的页面添加一个搜索框,调用谷歌的搜索API搜索所有公开分享文件// To add a search frame that calls the google cse api for searching some public shared files in BaiduYun cloud netdisk.

目前为 2014-05-22 提交的版本。查看 最新版本

// ==UserScript==
// @name       百度云插件+APIKey
// @namespace  
// @version    4.2 beta
// @description  在百度云网盘的页面添加一个搜索框,调用谷歌的搜索API搜索所有公开分享文件// To add a search frame that calls the google cse api for searching some public shared files in BaiduYun cloud netdisk. 

// @description  For more imformation,please email me at [email protected]. 
// @include       http://pan.baidu.com/disk/*
// @include      https://pan.baidu.com/disk/*
// @include      https://yun.baidu.com/#from=share_yun_logo/
// @include      http://yun.baidu.com/#from=share_yun_logo/
// @grant       none
// @run-at document-end
// @copyright  2014,04,20 __By Wang Hsin-che   
// ==/UserScript==
var url='https://www.googleapis.com/customsearch/v1element?key=AIzaSyCVAXiUzRYsML1Pv6RwSG1gunmMikTzQqY&rsz=filtered_cse&num=10&hl=en&prettyPrint=true&source=gcsc&gss=.com&sig=ee93f9aae9c9e9dba5eea831d506e69a&cx=018177143380893153305:yk0qpgydx_e&q=';//&q=windows&start=0';
var showList='';
var totalResults=0;
var frontIndex=0;
var pageIndex=0;
var tempNode;

var myDivHeight=window.innerHeight/4*3;
var myDivWidth=window.innerWidth/2;
var myDivLeft=-window.innerWidth/6;
var myDivTop=window.innerHeight/8;


var html_1='<div><input class="wxz-search-query" placeholder=" 搜索公开分享文件" id="wxz_input">\
			<input type="button" value="GO" class="wxz-search-button" id="wxz_searchButton"></div>';

var html_2='\
<div>\
	<div class="wxz-myDiv" style="display: none;">\
		<div class="wxz-title">\
			<a class="wxz-close" id="wxz_closeButton"><b><font color="#ffffff" size="3">x</font></b></a>\
			</div>\
				<div class="wxz-content">\
				</div>\
			<div>\
			<a class="wxz-next" id="wxz_nextPageButton"><font color="#333">[-->]</font></a>\
			<a class="wxz-front" id="wxz_frontPageButton"><font color="#333">[<--]</font></a>\
		</div>\
	</div>\
</div>\
';


var cssText='\
<style type="text/css">\
	.wxz-title{background:#353636};\
	.wxz-search-query{ padding: 0px; margin: 0px; height: auto; outline: none; background-color: rgb(255, 255, 255); background-position: 0% 50%; background-repeat: no-repeat no-repeat;}\
	.wxz-search-button{margin-left: -2px;cursor:pointer;background-color: rgb(155, 154, 154); border-bottom-color: rgb(102, 102, 102);border-bottom-style: solid;border-bottom-width: 1px;border-collapse: separate;border-left-color: rgb(102, 102, 102);border-left-style: solid;border-left-width: 1px;border-right-color: rgb(102, 102, 102);border-right-style: solid;border-right-width: 1px;border-top-color: rgb(102, 102, 102);border-top-style: solid;border-top-width: 1px;color: #ffffff;height: auto;width: 30px;}\
		.wxz-myDiv{display:none;z-index:99;box-shadow:0 0 9px rgba(0,0,0,.9);background:#FFFFFF;position:absolute;outline:0 none;}\
		.wxz-content{line-height: 200%;text-align: left;white-space: normal;margin-left:20px;overflow:scroll;}\
		.wxz-close{margin-right:20px;important;height:20px;cursor:pointer}\
		.wxz-next{margin-right:20px;float:right;height:20px;cursor:pointer}\
		.wxz-front{margin-right:40px;float:right;height:20px;cursor:pointer}\
		.wxz-content a{color:#0066FF!important;font: 14px/1.5 arial,sans-serif!important;}\
</style>\
				';


$('#top_menu_other').replaceWith(html_1);//搜索栏替换了广告	
$('.info:eq(0)').append(html_2);
$('head:first').append(cssText);



$('.wxz-content').height(myDivHeight).width(myDivWidth);
$('.wxz-myDiv').offset({ top: myDivTop, left: myDivLeft })




$(wxz_searchButton).click(function(){frontIndex=0;pageIndex=0;search($(wxz_input).val());});
$(wxz_closeButton).click(function(){searchClear();});
$(wxz_nextPageButton).click(function(){if(pageIndex<totalResults){search($(wxz_input).val());}else{alert("It is the last page!");}});
$(wxz_frontPageButton).click(function(){if(frontIndex>=0){pageIndex=frontIndex;search($(wxz_input).val());}else{alert("It is the top page!");}});
$(wxz_input).keyup(function(event){if(event.which==13){$(wxz_searchButton).trigger('click');}});


function searchClear(){
	$('.wxz-myDiv').slideUp();
	$(wxz_input).val('');
	showList='';
	tempNode='';
	frontIndex=0;
	pageIndex=0;
	$('.wxz-content').empty();//清空原来的内容
	console.log('clear');
}


function search(keyword){
	console.log('search');
	if (keyword==''){
		console.log('fail');
		return 1;
	}
	$('.wxz-content').html('<img src=http://www.scienceq.org/images/loading_pdf.gif>');
	$('.wxz-myDiv').slideDown();
	$.getJSON(url+keyword+'&start='+pageIndex,function(Data){	                                                                           
				frontIndex=pageIndex-10;
				totalResults=parseInt(Data.cursor.estimatedResultCount,10);
				$('.wxz-content').empty();//清空原来的内容
			showList="<p align='right'>---- by Google Custome Search </p><p white-space='normal' class='temp' >keyword is    '"+keyword+"'    found  '"+Data.cursor.resultCount+"'  Results</p><p>--------------------------------------------------<p>";
				$.each(Data.results,function(index,element){
					pageIndex++;
					tempNode='<a href="'+element.unescapedUrl+'"target="_blank">'+element.titleNoFormatting+'</a>';
					showList+='<p><p class="myTitle">'+tempNode+'</p>';
					showList+='<p class="mySnippet">'+element.contentNoFormatting+'</p>';
					});				
				showList+='<p><p>-------------------------------------------------------------<p class="temp" margin-left="20px">"'+pageIndex+'"  items have been load </p><p align="right"><a href="http://userscripts.org/users/608364" target="_blank"><font color="#333">About me</font></a></p>';
				$('.wxz-content').append(showList);//必须用+=  然后一次性添加  否则会刷新原来的内容
        if(Data.cursor.resultCount==0){$('.wxz-content').html('<div align="center"><img  src=http://blog.fpweb.net/media/2011/11/No-Search-Results-325x287.png></div>');}
				$('.wxz-content').scrollTop(0);//到顶端
			}).fail(function() {
        $('.wxz-content').html('<img src=http://icongal.com/gallery/image/297514/cancel_quit_terminate_exit_error_close_delete.png>');
			console.log( "error" );																												
		  })
		  .always(function() {
			console.log( "search and list complete" );
		  });
	}


















QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址