Oscar.Container

Oscar's Container

Questo script non dovrebbe essere installato direttamente. È una libreria per altri script da includere con la chiave // @require https://update.greatest.deepsurf.us/scripts/12696/76930/OscarContainer.js

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        Oscar.Container
// @namespace   Oscar.Container
// @description Oscar's Container
// @version     2015.09.26.01
// @author Oscar Koo
// @grant       none
// @noframes
// ==/UserScript==

(function(e,t){if(typeof ok=="undefined"||!ok.isTopWindow())return;function n(e){var n=this;var r=(new Date).getTime();var o;this.checkInterval=2e4;this.checkServer=true;var c=t.getElementById(e);var i=e+"_Cache";(function(){var e=ok.readLocal(i);n.checkServer=e.checkServer?true:false})();var a=function(){};var l=function(e,t){};var v=function(){var e=(new Date).getTime();var t=new XMLHttpRequest;try{t.open("HEAD","#",true);t.setRequestHeader("Range","bytes=-1");t.onreadystatechange=function(){if(t.readyState===2)l(t,e)};t.send(null)}catch(n){console.debug(n);l(t,e)}};var s=function(){if(n.checkServer)v();else a()};a=function(){r=(new Date).getTime();setTimeout(s,n.checkInterval)};l=function(e,t){var c=(new Date).getTime();var i=e.getResponseHeader("Date");if(o!==i){o=i;r=new Date(i).getTime()+parseInt((c-t)/2,10);setTimeout(s,n.checkInterval)}else{n.toggleCheck(false);a()}};var u=function(){var e=new Date(r);var t=e.format("hh:mm:ss");c.innerHTML=t;r+=1e3;setTimeout(u,1e3);n.onTickTock(e.format("yyyy-MM-dd"),t)};this.run=function(){s();u()};this.toggleCheck=function(e){n.checkServer=typeof e=="boolean"?e:!n.checkServer;ok.writeLocal(i,{checkServer:n.checkServer});n.onToggleCheck()};this.onToggleCheck=function(){};this.onTickTock=function(e,t){}}function r(e,n){var r=this;var o=true;var c=null;this.addComponent=function(e){ok.addHtml(e,c)};this.serverClock=null;(function(){if(!t.getElementById(e)){var i=e+"_Left";var a=e+"_Right";var l=e+"_Container_Cache";ok.addHtml('<div id="'+e+'" style="position:fixed;top:100px;left:0;opacity:0.7;font-family:verdana;font-size:12px;z-index:999999">'+'<div id="'+i+'" style="float:left;background:red;cursor:pointer;width:8px;min-height:23px"></div>'+'<div id="'+a+'" style="float:left"></div>'+"</div>");var v=ok.readLocal(l);o=!v.show?true:false;c=t.getElementById(a);var s=t.getElementById(i);s.onclick=function(){o=!o;ok.writeLocal(l,{show:o});c.style.display=o?"":"none"};s.onclick();if(n){var u=e+"_ServerClock";var f=e+"_btnServerClock";r.addComponent('<div>服务器时间: <span id="'+u+'"></span><input type="button" id="'+f+'" style="width:80px"></div>');r.serverClock=ok.CreateServerClock(u);var d=t.getElementById(u);var k=t.getElementById(f);r.serverClock.onToggleCheck=function(){k.value=r.serverClock.checkServer?"本地时间":"服务器时间";d.style.color=r.serverClock.checkServer?"red":""};k.value=function(){d.style.color=r.serverClock.checkServer?"red":"";return r.serverClock.checkServer?"本地时间":"服务器时间"}();k.onclick=function(){setTimeout(r.serverClock.toggleCheck,0)};r.serverClock.run()}}})()}function o(e,n){if(!n||typeof n!="number")n=0;n=parseInt(n,10);var r=[];var o=t.getElementById(e);this.clear=function(){r=[];o.innerHTML=""};this.write=function(e){var t="["+(new Date).format("hh:mm:ss.f")+"] ";setTimeout(function(){r.push(t+e);var c=r.length-n;if(c>0)r.splice(0,c);o.innerHTML=r.join("<br>")},0)}}ok.extend({CreateContainer:function(e,t){return new r(e,t)},CreateServerClock:function(e){return new n(e)},CreateLog:function(e,t){return new o(e,t)}})})(window,document);