// ==UserScript== // @name OGame Hidden Colony // @description Shows the update timestamp of your planet APIs, helping you to make a hidden colony to hide your activity. // @namespace https://github.com/EliasGrande/ // @icon https://github.com/EliasGrande/OGameHiddenColony/raw/master/dist/img/icon.png // @version 1.0.2 // @include *://*.ogame.*/game/index.php?*page=* // @include *://*.ogame.gameforge.*/game/index.php?*page=* // @downloadURL none // ==/UserScript== /*! OGame Hidden Colony (C) 2016 Elías Grande Cásedas | MIT | opensource.org/licenses/MIT */ (function(){var h=window,t;try{if(unsafeWindow){h=unsafeWindow}}catch(r){}t=h.document;const q="o_hidden_colony_";const m=10;var u={UNIVERSE:[{NAME:"AntigameOrigin",URL:"antigame.de"},{NAME:"Ogniter",URL:"www.ogniter.org"}],PLAYER_DATA:[{NAME:"GalaxyInfo",URL:"userscripts-mirror.org/scripts/show/136509"}]};var j={UNIVERSE:"{uni}/api/universe.xml",PLAYER_DATA:"{uni}/api/playerData.xml?id={pid}"};var p=function(w,v){for(var e in v){if(!v.hasOwnProperty(e)){continue}if(v[e].constructor==Object){if(!w.hasOwnProperty(e)){w[e]={}}w[e]=p(w[e],v[e])}else{w[e]=v[e]}}return w};var l=function(e){return Math.round((new Date(e)).getTime()/1000)};var n=function(){this._universe=this.getMeta("universe").trim();this._playerId=parseInt(this.getMeta("player-id"));this._timestamp=parseInt(this.getMeta("timestamp"));this._language=this.getMeta("language").trim();var w;try{w=this.query("#ago_clock_server").childNodes[0].nodeValue.replace(/\d+\D\d+\D\d{4}/,"")}catch(y){w=this.query(".OGameClock span").childNodes[0].nodeValue}w=w.replace(/^\D+/,"").replace(/\D+$/,"").split(/\D/);w=parseInt(w[0])*3600+parseInt(w[1])*60+parseInt(w[2]);var x=this._timestamp;x=x/86400;x=Math.round((x-Math.floor(x))*86400);var v=Math.round((w-x)/60);if(v<(-720)){v=v+1440}else{if(v>720){v=v-1440}}this._gmtOffset=v};n.prototype={query:function(e){return t.querySelector(e)},getMeta:function(e){return this.query('meta[name="ogame-'+e+'"]').getAttribute("content")},getUniverse:function(){return this._universe},getPlayerId:function(){return this._playerId},getTimestamp:function(){return this._timestamp},getLanguage:function(){return this._language},getGmtOffset:function(){return this._gmtOffset}};var d=function(v){var e=new Date();this._offset=(v+e.getTimezoneOffset())*60};d.prototype={timestampToLocaleString:function(x){var v=new Date(x*1000);var e=v.getHours();if(e<10){e="0"+e.toString()}var w=v.getMinutes();if(w<10){w="0"+w.toString()}var y=v.getSeconds();if(y<10){y="0"+y.toString()}return v.toLocaleDateString()+" "+e+":"+w+":"+y},timestampToOgameString:function(e){return this.timestampToLocaleString(e+this._offset)},countdownCompleted:"00:00:00",timestampToCountdownString:function(x){var v=Math.round((x*1000-(new Date()).getTime())/1000);if(v<0){return this.countdownCompleted}var e=Math.floor(v/3600);v=v-e*3600;var w=Math.floor(v/60);var y=v-w*60;return((e<10)?"0":"")+e.toString()+":"+((w<10)?"0":"")+w.toString()+":"+((y<10)?"0":"")+y.toString()},initCountdown:function(A,y){var x=A;var z=y;var e=this;var v;var w=function(){x.nodeValue=e.timestampToCountdownString(z);if(x.nodeValue==e.countdownCompleted){clearInterval(v)}};v=setInterval(w,1000)}};var a=function(e){this._prefix=q+e.getUniverse()+"_"};a.prototype={_obj:h.localStorage,get:function(v){var e=this._obj.getItem(this._prefix+v);return(e==null)?null:JSON.parse(e)},set:function(v,e){return this._obj.setItem(this._prefix+v,JSON.stringify(e))},remove:function(e){return this._obj.removeItem(this._prefix+e)}};var s=function(e,v){this._headers=e.get(v)};s.prototype={getHeaders:function(e){e(this._headers)},needUpdate:function(w){try{if(this._headers==null){return true}var v=this._headers.expires;var y=this._headers.date;return((v