Tieba Utilities

百度贴吧依赖脚本(寂寞的原子的公共库)

Versione datata 05/03/2014. Vedi la nuova versione l'ultima versione.

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

You will need to install an extension such as Tampermonkey to install this script.

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==UserScript==
// @name	Tieba Utilities
// @namespace	http://gera2ld.blog.163.com/
// @author	Gerald <[email protected]>
// @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
// ==/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<i.hook_before.length;t++)if(r=i.hook_before[t].apply(n,[i,o]),a)return r;for(r=i.hook_func.apply(n,o),t=0;t<i.hook_after.length;t++)if(e=i.hook_after[t].apply(n,[i,r,o]),void 0!==e&&(r=e),a)return r;return r},e[t].hook_func=o,o=e[t],o.hooked=!0,o.hook_after=[],o.hook_before=[]),e=o.hook_after,(t=n.after)&&(t.concat?o.hook_after=e.concat(t):e.push(t)),e=o.hook_before,(t=n.before)&&(t.concat?o.hook_before=e.concat(t):e.push(t)))},addStyle:function(e,t){var n=document.getElementById(t)||document.createElement("style");return t&&(n.id=t),e&&(n.innerHTML=e),document.head.appendChild(n),r?r(n):n},getObj:function(e,t){var n=localStorage.getItem("ge_"+e),o=void 0,i=o;if(n)try{i=JSON.parse(n)}catch(r){}return i==o&&t!=o&&(i=d.setObj(e,t)),i},setObj:function(e,t){return localStorage.setItem("ge_"+e,JSON.stringify(t)),t},addButton:function(e,t,n,o){if(o||(o={}),n){var i,a=o.keys;for(a&&a.length||(a=["mousedown","mouseup"]),i=0;i<a.length;i++)if(t[a[i]]){t[a[i]].call(t,n);break}}return e=r(e),o.after?t.insertAfter(e.children(o.after)):o.before?t.insertBefore(e.children(o.before)):t.appendTo(e),t},addTButton:function(e,t){var n=r("div.edui-btn-toolbar").first();return t&&e.click(t),e.appendTo(r('<div class="edui-btn edui-btn-bold" unselectable="on" onmousedown="return false">').prependTo(n))},addSButton:function(e){var t=r('<a href="#" class="ui_btn ui_btn_m poster_submit">').insertBefore(".poster_draft_status").html("<span><em>"+e+"</em></span>");return t},addPopup:function(e,t,n){var o=r('<div class=ge_panel_p title="">').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("<i class=ge_caret>").appendTo(o).html("<i></i>"),o.panel=r("<div class=ge_panel>").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=["<a"];for(i in t)n.push(i+'="'+t[i]+'"');return n.join(" ")+">"+e+"</a>"},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;