// ==UserScript== // @name Tieba Utilities // @namespace http://gera2ld.blog.163.com/ // @author Gerald // @icon http://s.gravatar.com/avatar/a0ad718d86d21262ccd6ff271ece08a3?s=80 // @version 0.7 // @description 百度贴吧依赖脚本(寂寞的原子的公共库) // @homepage http://userscripts.org/scripts/show/400102 // @match *://*.baidu.com/* // @include *.baidu.com/* // @run-at document-start // @downloadURL none // ==/UserScript== function e(){o={},document.addEventListener("keydown",function(e){if(e.target==document.body){var t,n=[];e.ctrlKey&&n.push("c"),e.altKey&&n.push("a"),e.shiftKey&&n.push("s"),e.metaKey&&n.push("m"),n.push(String.fromCharCode(e.keyCode)),n=n.join("-").toLowerCase(),(t=o[n])&&(e.preventDefault(),t())}},!1)}var t={},n=[],o=null,r=function(){return r=unsafeWindow.$,r.apply(this,arguments)},a={common:"http://gerald.gitcafe.com/TiebaCommon.html#hotkey",advanced:"http://gerald.gitcafe.com/TiebaAdvanced.html#advanced"},d={wait:function(e,o,i,r){function a(){e[o]?(delete t[d],s.forEach(function(t){t(e[o])})):setTimeout(a,r)}var d=n.indexOf(e);0>d&&(d=n.length,n.push(e)),d+="."+o;var s=t[d];s?r=0:(r||(r=500),s=t[d]=[]),s.push(i),r&&a()},hook:function(e,t,n){var o;e&&(o=e[t])&&(o.hooked||(e[t]=function(){var e,t,n=this,o=arguments,i=o.callee,r=void 0,a=!1;for(i.hookStop=function(){a=!0},t=0;t').prependTo(n))},addSButton:function(e){var t=r('').insertBefore(".poster_draft_status").html(""+e+"");return t},addPopup:function(e,t,n){var o=r('
').appendTo(e).click(function(e){e.stopPropagation(),["A","BUTTON"].indexOf(e.target.tagName)>=0&&e.preventDefault()}).hide(),i=".ui_btn_m,.edui-btn";return o.holder=e,o.caret=r("").appendTo(o).html(""),o.panel=r("
").appendTo(o),o.onclose=function(){o.hide(),r(document).unbind("click",o.onclose)},o.onopen=function(){o.show(),r(document).click(o.onclose),n&&n(o);var t=e.offset(),i=o.button.offset(),a=o.offsetParent(),d=Math.min(i.left-t.left-50,r(document.body).innerWidth()-t.left-o.panel.outerWidth()-20);o.css({"margin-left":d,bottom:a.height()-i.top+a.offset().top+parseInt(a.css("padding-top"))}),o.caret.css({left:i.left-t.left-d})},o.ontoggle=function(e){e.preventDefault(),o.button=r(e.target).parents(i).addBack(i),o.is(":visible")?o.onclose():setTimeout(o.onopen,0)},t&&t.click(o.ontoggle),o},bindProp:function(e,t,n,o,i,r){return e.prop(t,d.getObj(n,o)),r||(r=["change"]),r.forEach(function(o){e.bind(o,function(o){d.setObj(n,this[t]),i&&e.each(function(e,t){i.call(t,o)})})}),e},shortcut:function(t,n){o||e(),t=t.toLowerCase();var i=[];"--"==t.slice(-2)?(i.push("-"),t=t.slice(0,-2).split("-")):t=t.split("-"),(t.indexOf("m")>=0||t.indexOf("meta")>=0)&&i.unshift("m"),(t.indexOf("s")>=0||t.indexOf("shift")>=0)&&i.unshift("s"),(t.indexOf("a")>=0||t.indexOf("alt")>=0)&&i.unshift("a"),(t.indexOf("c")>=0||t.indexOf("ctrl")>=0)&&i.unshift("c"),t=t.join("-"),n?o[t]=n:delete o[t]},list:function(e,t,n,o){var i={};return i.last=0,i.load=function(e,n){return void 0==e&&(e=t?d.getObj(t,0):0),0>e||!i.length?e=0:e>=i.length&&(e=i.length-1),t&&!n&&d.setObj(t,e),i.cur=i.list[i.last=e],i},i.push=function(e){return e||(e=n()),i.list.push(e),i.save(),i.length-1},i.pop=function(e){var t=i.list.splice(e,1)[0];return i.save(),i.load(e),t},i.save=function(){e&&d.setObj(e,i.list),t&&d.setObj(t,i.last)},i.list=e?d.getObj(e,[]):[],i.__defineGetter__("length",function(){return i.list.length}),!i.length&&o&&(o.concat?(i.list=o.concat(),i.save()):i.push()),i},getLink:function(e,t){t=t||{};var n=a[e];n&&(t.href=n),t.target||(t.target="_blank"),e=t.html||"",delete e.html,n=[""+e+""},popup:{dialog:null,show:function(e){var t=this,n=t.dialog;t.hide(),t.obj=e,n.className=e.className||"",n.innerHTML=e.html,e.init&&e.init(n),n.style.display="block",n.style.top=(innerHeight-n.offsetHeight)/2+"px",n.style.left=(innerWidth-n.offsetWidth)/2+"px",document.addEventListener("click",t._hide=t.hide.bind(this),!1)},hide:function(){var e=this,t=e.obj,n=e.dialog;t&&(t.dispose&&t.dispose(n),n.style.display="none",e.obj=null,document.removeEventListener("click",e._hide,!1))}}};window.addEventListener("DOMContentLoaded",function(){var e=document.createElement("div");e.id="ge_popup",document.body.appendChild(e),e.addEventListener("click",function(e){e.stopPropagation()},!1),d.popup.dialog=e,d.addStyle(".ge_x{clear:both;}#ge_popup{z-index:10006;font:normal normal 400 12px/18px 宋体;position:fixed;background:white;border:1px solid silver;box-shadow:5px 5px 7px #333;text-align:left;}.ge_mask{background:rgba(0,0,0,0.6);position:fixed;top:0;bottom:0;left:0;right:0;z-index:999;display:none;}.ge_panel_p{position:relative;z-index:888;height:1px;}.ge_panel{position:absolute;background:#eee;border:1px solid black;padding:10px;border-radius:10px;z-index:888;bottom:0;}.ge_caret,.ge_caret>i{position:absolute;border:solid;border-color:black transparent;border-width:8px 8px 0;z-index:889;}.ge_caret>i{border-top-color:#eee;top:-9px;left:-8px;}.ge_sbtn{background:#77f;color:white;border-radius:3px;border:1px solid;border:none;margin:2px;cursor:pointer;text-align:center;}span.ge_sbtn{padding:2px 3px;}.ge_disabled{background:gray;cursor:default;}.ge_rsep{margin-right:10px;}.ge_opt{padding:20px;border-radius:5px;}.ge_opt fieldset{border:1px solid silver;border-radius:5px;padding:5px;}.ge_opt textarea{min-height:100px;width:100%;}","ge_css")},!1);var s=null,l="__ge_firefox";s=unsafeWindow[l],s||(s=unsafeWindow[l]={}),(s||window).utils=d;