// ==UserScript== // @name 百度云插件+APIKey // @namespace // @version 4.3.1 beta // @description 在百度云网盘的页面添加一个搜索框,调用谷歌的搜索API搜索所有公开分享文件// To add a search frame that calls the google cse api for searching some public shared files in BaiduYun cloud netdisk. // @require http://code.jquery.com/jquery-2.1.1.min.js // @description For more imformation,please email me at wang0xinzhe@gmail.com. // @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 GM_xmlhttpRequest // @run-at document-end // @copyright 2014,04,20 __By Wang Hsin-che // @downloadURL none // ==/UserScript== (function($) { $.fn.draggable = function(options) { var settings = $.extend({ handle: undefined, msg: {}, callfunction: function() {} }, options); var _eleFunc = function() { var x0, y0, ele = $(this), handle; handle = (settings.handle === undefined ? ele : ele.find(settings.handle).eq(0) === undefined ? ele : ele.find(settings.handle).eq(0)); ele.css({ position: "absolute" }); //make sure that the "postion" is "absolute" handle.bind('mousedown', function(e0) { handle.css({ cursor: "move" }); //set the appearance of cursor x0 = ele.offset().left - e0.pageX; //*1 y0 = ele.offset().top - e0.pageY; //*1 $(document).bind('mousemove', function(e1) { //bind the mousemove event, caution:this event must be bind to "document" ele.css({ left: x0 + e1.pageX, top: y0 + e1.pageY }); //this expression and the expression of *1 equal to "ele.origin_offset+mouse.current_offset-mouse.origin_offset" }); $(document).one('mouseup', settings.msg, function(e) { //when the mouse up,unbind the mousemove event,bind only once settings.callfunction(e); //callback function $(document).unbind('mousemove'); handle.css({ cursor: "auto" }); }); }); // 從這裡開始 }; return this.each(_eleFunc); }; })(jQuery); ///////////////////////////////////////////////////////////////////////////////////////////////////////////// ////// /////定义 var SearchObject = function($, replaceEle) { 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=', keyword = '', //搜索框的html html_1 = '\ ', //显示页面的html html_2 = '\
\ ', //插入的css cssText = '\ \ '; return { searchClear: function() { $('#wxz_myDiv').slideUp(); $('#wxz_input').val(''); keyword = ''; $('.wxz-content').empty(); //清空原来的内容 console.log('clear'); }, search: function(keyword, startIndex) { console.log('search'); var self = this; if (keyword === '') { console.log('fail'); return 0; } //显示loading条 $('.wxz-content').html('---- by Google Custome Search
keyword is '" + keyword + "' found '" + data.cursor.resultCount + "' Results
--------------------------------------------------
"; $.each(data.results, function(index, element) { tempNode = '' + element.titleNoFormatting + ''; showList += '
' + tempNode + '
'; showList += '' + element.contentNoFormatting + '
'; }); showList += '-------------------------------------------------------------
"' + data.results.length + '" items have been load
'; $('.wxz-content').html(showList); //替换原来内容,之所以用了showlist作为缓存是为了提升速度 $('.wxz-content').scrollTop(0); //滚到顶端 } self.pageBar(parseInt(startIndex / 10, 10) + 1, totalPage); data = null; tempNode = null; totalPage = null; totalResults = null; showList = null; }, onerror: function() { $('.wxz-content').html('