Greasy Fork is available in English.

Oscar.Library

Oscar's Library

Este script não deve ser instalado diretamente. Este script é uma biblioteca de outros scripts para incluir com o diretório meta // @require https://update.greasyfork.org/scripts/12695/76928/OscarLibrary.js

// ==UserScript==
// @name        Oscar.Library
// @namespace   Oscar.Library
// @description Oscar's Library
// @version     2015.09.27.02
// @author Oscar Koo
// @grant       none
// @noframes
// ==/UserScript==

(function(e,t){var n=function(e,t){e.prototype=e.prototype||{};for(var n in t){e[n]=e.prototype[n]=t[n]}};n(Date,{format:function(e){var t={"M+":this.getMonth()+1,"d+":this.getDate(),"h+":this.getHours(),"m+":this.getMinutes(),"s+":this.getSeconds(),"q+":Math.floor((this.getMonth()+3)/3)};if(/(y+)/.test(e))e=e.replace(RegExp.$1,(this.getFullYear()+"").substr(4-RegExp.$1.length));var n,r;if(/(f+)/.test(e))e=e.replace(RegExp.$1,("000"+(n=this.getMilliseconds())).substr((""+n).length));for(var o in t)if(new RegExp("("+o+")").test(e))e=e.replace(RegExp.$1,RegExp.$1.length===1?t[o]:("00"+(r=t[o])).substr((""+r).length));return e}});var r=e.ok||function(){return new r.prototype.Init};r.prototype.constructor=r;r.prototype.Init=function(){return this};r.extend=r.prototype.extend=function(e){n(this,e);return this};r.extend({costs:function(e,t){var n=(new Date).getTime();if(typeof t=="function")t();var r=(new Date).getTime();console.debug(e+" costs: "+(r-n)+"ms.")}});r.extend({isTopWindow:function(){try{return self.frames.location.href===top.location.href}catch(e){return false}}});var o=function(e){return e?localStorage:sessionStorage};var s=function(e,t){return JSON.parse(unescape(o(e).getItem(t)))||{}};var i=function(e,t,n){o(e).setItem(t,escape(JSON.stringify(n||{})))};var a=function(e,t){if(t)o(e).removeItem(t);else o(e).clear()};r.extend({readLocal:function(e){return s(true,e)},readSession:function(e){return s(false,e)},writeLocal:function(e,t){i(true,e,t)},writeSession:function(e,t){i(false,e,t)},removeLocal:function(e){a(true,e)},removeSession:function(e){a(false,e)}});var u=t.getElementsByTagName("header")[0];var f=t.getElementsByTagName("body")[0];r.extend({addCss:function(e){var n=t.createElement("style");n.type="text/css";n.innerHTML=e;u.appendChild(n);return this},createHtmlNodes:function(e){var n=t.createElement("temp");n.innerHTML=e;return n.childNodes},addHtml:function(e,n){var r=this.createHtmlNodes(e);var o=r.length;if(!n)n=f;else if(typeof n=="string")n=t.querySelector(n);else if(typeof n=="function")n=n();for(var s=0;s<o;s++){n.appendChild(r[0])}return this},addBefore:function(e,t){var n=t.parentElement;var r=this.createHtmlNodes(e);var o=r.length;for(var s=0;s<o;s++){n.insertBefore(r[0],t)}}});var c=[];var l=function(e,t,n){c.push({element:e,event:t,func:n})};var p=function(e,t,n){for(var r=0;r<c.length;r++){var o=c[r];if(o.element===e&&o.event===t&&o.func===n)return true}return false};r.extend({event:function(e,n,r){e=t.querySelector(e);var o=function(t,n){if(t.target!==e)return;n(t)};for(var s=1;s<arguments.length;s++){var i=arguments[s];var a=arguments[++s];if(p(e,i,a))continue;l(e,i,a);var u=function(e){o(e,a)};e.addEventListener(i,u,false)}return this}});r.extend({query:function(e,t,n,r,o){if(typeof t=="function"){o=r;r=n;n=t;t=undefined}r=r||"POST";o=o===false?false:true;var s=r.toUpperCase()==="POST";var i=new XMLHttpRequest;try{i.onreadystatechange=function(){try{if(i.readyState==4&&i.status==200&&typeof n=="function")n(i.response,i.responseText,i)}catch(e){console.debug(e);if(typeof n=="function")n(i.response,i.responseText,i,false)}};i.open(r,e,o);if(s){if(typeof t=="object")t=this.jsonToQueryString(t);i.setRequestHeader("Content-type","application/x-www-form-urlencoded");i.setRequestHeader("Content-length",(t||"").length);i.setRequestHeader("Connection","close")}i.send(s&&t?t:null)}catch(a){console.debug(a);if(typeof n=="function")n(i.response,i.responseText,i,false)}},jsonToQueryString:function(e){return Object.keys(e).map(function(t){return encodeURIComponent(t)+"="+encodeURIComponent(e[t])}).join("&")}});e.ok=r})(window,document);