// ==UserScript== // @name VDex Project Berry Timer // @namespace Http://www.enbewe.de/vdex // @description Shows timers for Berries // @include http://vdexproject.net/berries.php* // @version 1 // ==/UserScript== var oldFunction = unsafeWindow.sendRequest; unsafeWindow.sendRequest = function(xmlhttp, target, params) { // alert('Captured\n'+xmlhttp+' '+target+' '+params); var regex = /berryplant&berry=\w+&slot=(\w+)/ if (regex.test(params)){ regex.exec(params); var slot = RegExp.$1; // alert('Planting'+slot); setTimeout(function() { var dat = new Date().getTime(); GM_setValue(slot, dat+''); }, 0); } oldFunction(xmlhttp,target,params); } var anchor = document.getElementById('berrymsg'); var berryTimerDiv = document.createElement('div'); berryTimerDiv.setAttribute('id','berryTimer'); berryTimerDiv.setAttribute('style','text-align:center;'); anchor.parentNode.insertBefore(berryTimerDiv,anchor); for (var i = 0; i < 4; i++) { var timest = GM_getValue('slot'+i,''); if (timest != '') { timest = parseInt(timest); var time = ((new Date().getTime() - timest)/1000)/60; var text = Math.floor(time/60)+' Stunden und '+Math.floor(time%60)+' Minuten'; berryTimerDiv.innerHTML += 'Slot '+(i+1)+': '+text+'
'; } else { berryTimerDiv.innerHTML += 'Slot '+(i+1)+': Nicht definiert
'; } }