Pushing Scripts to GitLab
This commit is contained in:
commit
047edb0035
9 changed files with 954 additions and 0 deletions
302
VDex_Project_Ajax_Cature.user.js
Executable file
302
VDex_Project_Ajax_Cature.user.js
Executable file
|
@ -0,0 +1,302 @@
|
||||||
|
// ==UserScript==
|
||||||
|
// @name VDex Project Ajax capture
|
||||||
|
// @namespace Http://www.enbewe.de/vdex
|
||||||
|
// @description Tries to capture Ajax events
|
||||||
|
// @include http://vdexproject.net/dungeon.php?mode=navigate*
|
||||||
|
// @version 0.1
|
||||||
|
// ==/UserScript==
|
||||||
|
|
||||||
|
// Control flags
|
||||||
|
var maincontrol = false;
|
||||||
|
var travel = false;
|
||||||
|
var take_skills = false;
|
||||||
|
var autobattle = false;
|
||||||
|
|
||||||
|
// Status variables
|
||||||
|
var mode = 'unknown';
|
||||||
|
var room = '';
|
||||||
|
var lastDirection = 'east';
|
||||||
|
|
||||||
|
// Create control window
|
||||||
|
// TODO: create option to minimize
|
||||||
|
var controlWindow = document.createElement('div');
|
||||||
|
controlWindow.setAttribute('style','width:180px; height:180px; position: fixed; top: 10px; left: 10px; background: #232323; border: 3px solid grey; padding: 10px;');
|
||||||
|
document.getElementById('login').parentNode.appendChild(controlWindow);
|
||||||
|
refreshControlWindow();
|
||||||
|
|
||||||
|
function handleSend(send) {
|
||||||
|
var rege;
|
||||||
|
|
||||||
|
rege = /mode=changeroom&direction=(\w+)/;
|
||||||
|
if (rege.test(send)) {
|
||||||
|
rege.exec(send);
|
||||||
|
mode = 'roomchange';
|
||||||
|
// alert('Sending roomchange to '+RegExp.$1);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
rege = /mode=take&what=(\w+)/;
|
||||||
|
if (rege.test(send)) {
|
||||||
|
// alert('Taking skill disk');
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
rege = /mode=enterbattle/;
|
||||||
|
if (rege.test(send)) {
|
||||||
|
mode = 'battle';
|
||||||
|
// alert('Entering battle');
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
rege = /mode=battle/;
|
||||||
|
if (rege.test(send)) {
|
||||||
|
mode = 'battle';
|
||||||
|
// alert('Fighting');
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
mode = 'unknown'
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleResponse(response) {
|
||||||
|
if (maincontrol) {
|
||||||
|
var rege;
|
||||||
|
room = document.getElementById("thisroom");
|
||||||
|
|
||||||
|
var roomname = document.evaluate('//div[@id="thisroom"]/b[1]',document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.innerHTML;
|
||||||
|
// alert(roomname);
|
||||||
|
|
||||||
|
if (take_skills) {
|
||||||
|
rege = /There\sis\sa\sSKILL\sDISC/;
|
||||||
|
if (rege.test(room.innerHTML)) {
|
||||||
|
unsafeWindow.take('skill');
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (autobattle) {
|
||||||
|
if (mode == 'battle') {
|
||||||
|
var btlog = document.evaluate('//td[@class="btlog"]',document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.innerHTML;
|
||||||
|
rege = /defeated/
|
||||||
|
if (rege.test(btlog.toLowerCase())) {
|
||||||
|
mode = 'battledone';
|
||||||
|
unsafeWindow.endbattle();
|
||||||
|
setTimeout(function() {
|
||||||
|
handleResponse(response); }, 500+(Math.floor(Math.random()*800)));
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
mode = 'battle';
|
||||||
|
unsafeWindow.battle('ATTACK');
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
alert(btlog);
|
||||||
|
} else {
|
||||||
|
var playdata = document.getElementById('yourdata').innerHTML;
|
||||||
|
var playskills = document.getElementById('yourskills').innerHTML;
|
||||||
|
rege = /HP\s(\d+)\/(\d+)/
|
||||||
|
rege.exec(playdata);
|
||||||
|
var needHeal = (RegExp.$1 <= (RegExp.$2 / 3))
|
||||||
|
rege = /prayer/;
|
||||||
|
var hasPrayer = rege.test(playskills.toLowerCase());
|
||||||
|
rege = /rest/;
|
||||||
|
var hasRest = rege.test(playskills.toLowerCase());
|
||||||
|
|
||||||
|
if (needHeal && hasPrayer) {
|
||||||
|
unsafeWindow.rest(true);
|
||||||
|
} else if (needHeal && hasRest) {
|
||||||
|
unsafeWindow.rest(false);
|
||||||
|
} else {
|
||||||
|
rege = /There\sare\sENEMIES\sroaming\sthe\sroom/;
|
||||||
|
if (rege.test(room.innerHTML)) {
|
||||||
|
var enemy = document.evaluate('//span[starts-with(@id,"enemyicon")]',document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
|
||||||
|
var enemyid = enemy.getAttribute('id');
|
||||||
|
rege = /enemyicon\d+(\w)/;
|
||||||
|
rege.exec(enemyid);
|
||||||
|
mode = 'battle';
|
||||||
|
unsafeWindow.enterbattle(RegExp.$1);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (travel && roomname != 'FINAL ROOM') {
|
||||||
|
if (document.getElementById('north') != null) {
|
||||||
|
unsafeWindow.go('north');
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if (document.getElementById(lastDirection) != null) {
|
||||||
|
unsafeWindow.go(lastDirection);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if (lastDirection == 'east') {
|
||||||
|
lastDirection = 'west';
|
||||||
|
} else {
|
||||||
|
lastDirection = 'east';
|
||||||
|
}
|
||||||
|
if (document.getElementById(lastDirection) != null) {
|
||||||
|
unsafeWindow.go(lastDirection);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Setting up ajax capture
|
||||||
|
var OldXHR = unsafeWindow.XMLHttpRequest;
|
||||||
|
var NewXHR = function() {
|
||||||
|
var self = this;
|
||||||
|
var actualXHR = new OldXHR();
|
||||||
|
|
||||||
|
this.onopen = function(a,b,c,d,e) {
|
||||||
|
// alert('Open:\n'+a+'\n'+b+'\n'+c+'\n'+d+'\n'+e);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.onsend = function(a) {
|
||||||
|
if (handleSend(a) != 1) {
|
||||||
|
// alert('Send:\n'+a);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.ononreadystatechange = function() {
|
||||||
|
if (self.readyState == 4) {
|
||||||
|
setTimeout(function() {
|
||||||
|
if (handleResponse(self.responseText) != 1) {
|
||||||
|
// alert('onreadystatechange:\n'+self.responseText+'\n'+self.statusText+'\n'+self.responseXML);
|
||||||
|
}
|
||||||
|
}, 500+(Math.floor(Math.random()*800)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.requestHeaders = "";
|
||||||
|
this.requestBody = "";
|
||||||
|
|
||||||
|
// emulate methods from regular XMLHttpRequest object
|
||||||
|
this.open = function(a, b, c, d, e) {
|
||||||
|
self.openMethod = a.toUpperCase();
|
||||||
|
self.openURL = b;
|
||||||
|
if (self.onopen != null && typeof(self.onopen) == "function") { self.onopen(a,b,c,d,e); }
|
||||||
|
return actualXHR.open(a,b,c,d,e);
|
||||||
|
}
|
||||||
|
this.send = function(a) {
|
||||||
|
if (self.onsend != null && typeof(this.onsend) == "function") { self.onsend(a); }
|
||||||
|
self.requestBody += a;
|
||||||
|
return actualXHR.send(a);
|
||||||
|
}
|
||||||
|
this.setRequestHeader = function(a, b) {
|
||||||
|
if (self.onsetrequestheader != null && typeof(self.onsetrequestheader) == "function") { self.onsetrequestheader(a, b); }
|
||||||
|
self.requestHeaders += a + ":" + b + "\r\n";
|
||||||
|
return actualXHR.setRequestHeader(a, b);
|
||||||
|
}
|
||||||
|
this.getRequestHeader = function() {
|
||||||
|
return actualXHR.getRequestHeader();
|
||||||
|
}
|
||||||
|
this.getResponseHeader = function(a) { return actualXHR.getResponseHeader(a); }
|
||||||
|
this.getAllResponseHeaders = function() { return actualXHR.getAllResponseHeaders(); }
|
||||||
|
this.abort = function() { return actualXHR.abort(); }
|
||||||
|
this.addEventListener = function(a, b, c) { alert("not implemented yet"); }
|
||||||
|
this.dispatchEvent = function(e) { alert("not implemented yet"); }
|
||||||
|
this.openRequest = function(a, b, c, d, e) { alert("not implemented yet"); }
|
||||||
|
this.overrideMimeType = function(e) { alert("not implemented yet"); }
|
||||||
|
this.removeEventListener = function(a, b, c) { alert("not implemented yet"); }
|
||||||
|
|
||||||
|
|
||||||
|
// emulate callbacks from regular XMLHttpRequest object
|
||||||
|
actualXHR.onreadystatechange = function() {
|
||||||
|
|
||||||
|
// copy properties back from the actual XHR to the wrapper
|
||||||
|
self.readyState = actualXHR.readyState;
|
||||||
|
try {
|
||||||
|
self.status = actualXHR.status;
|
||||||
|
} catch (e) {}
|
||||||
|
try {
|
||||||
|
self.responseText = actualXHR.responseText;
|
||||||
|
} catch (e) {}
|
||||||
|
try {
|
||||||
|
self.statusText = actualXHR.statusText;
|
||||||
|
} catch (e) {}
|
||||||
|
try {
|
||||||
|
self.responseXML = actualXHR.responseXML;
|
||||||
|
} catch (e) {}
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (self.ononreadystatechange != null && typeof(self.ononreadystatechange) == "function") { self.ononreadystatechange(); }
|
||||||
|
} catch (e) {}
|
||||||
|
|
||||||
|
// onreadystatechange callback
|
||||||
|
if (self.onreadystatechange != null && typeof(self.onreadystatechange) == "function") { return self.onreadystatechange(); }
|
||||||
|
|
||||||
|
}
|
||||||
|
actualXHR.onerror = function(e) {
|
||||||
|
if (self.onerror != null) { return self.onerror(e); }
|
||||||
|
}
|
||||||
|
actualXHR.onload = function(e) {
|
||||||
|
if (self.onload != null) { return self.onload(e); }
|
||||||
|
}
|
||||||
|
actualXHR.onprogress = function(e) {
|
||||||
|
if (self.onprogress != null) { return self.onprogress(e); }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
unsafeWindow.XMLHttpRequest = NewXHR;
|
||||||
|
|
||||||
|
// Control window contents
|
||||||
|
function refreshControlWindow() {
|
||||||
|
controlWindow.innerHTML = '<div style="text-align: center;"><b>Dungeon Crawler</b><br /><br />';
|
||||||
|
// Loot skills
|
||||||
|
var controlWindow_skills = document.createElement('div');
|
||||||
|
controlWindow_skills.setAttribute('id','controlWindow_skills');
|
||||||
|
controlWindow_skills.setAttribute('style','text-align: center;');
|
||||||
|
controlWindow_skills.innerHTML = '<a>Auto take skills: ';
|
||||||
|
|
||||||
|
if (take_skills) {
|
||||||
|
controlWindow_skills.innerHTML += '<span style="color: #008000;">active</span>';
|
||||||
|
} else {
|
||||||
|
controlWindow_skills.innerHTML += '<span style="color: #BF0000;">inactive</span>';
|
||||||
|
}
|
||||||
|
controlWindow_skills.innerHTML += '</a>';
|
||||||
|
controlWindow_skills.addEventListener("click", function() { take_skills = !take_skills; refreshControlWindow();}, true);
|
||||||
|
|
||||||
|
controlWindow.appendChild(controlWindow_skills);
|
||||||
|
// Fight
|
||||||
|
var controlWindow_battle = document.createElement('div');
|
||||||
|
controlWindow_battle.setAttribute('id','controlWindow_battle');
|
||||||
|
controlWindow_battle.setAttribute('style','text-align: center;');
|
||||||
|
controlWindow_battle.innerHTML = '<a>Auto battle: ';
|
||||||
|
if (autobattle) {
|
||||||
|
controlWindow_battle.innerHTML += '<span style="color: #008000;">active</span>';
|
||||||
|
} else {
|
||||||
|
controlWindow_battle.innerHTML += '<span style="color: #BF0000;">inactive</span>';
|
||||||
|
}
|
||||||
|
controlWindow_battle.innerHTML += '</a>';
|
||||||
|
controlWindow_battle.addEventListener("click", function() { autobattle = !autobattle; refreshControlWindow();}, true);
|
||||||
|
controlWindow.appendChild(controlWindow_battle);
|
||||||
|
// Travel
|
||||||
|
var controlWindow_travel = document.createElement('div');
|
||||||
|
controlWindow_travel.setAttribute('id','controlWindow_travel');
|
||||||
|
controlWindow_travel.setAttribute('style','text-align: center;');
|
||||||
|
controlWindow_travel.innerHTML = '<a>Auto travel: ';
|
||||||
|
if (travel) {
|
||||||
|
controlWindow_travel.innerHTML += '<span style="color: #008000;">active</span>';
|
||||||
|
} else {
|
||||||
|
controlWindow_travel.innerHTML += '<span style="color: #BF0000;">inactive</span>';
|
||||||
|
}
|
||||||
|
controlWindow_travel.innerHTML += '</a>';
|
||||||
|
controlWindow_travel.addEventListener("click", function() { travel = !travel; refreshControlWindow();}, true);
|
||||||
|
controlWindow.appendChild(controlWindow_travel);
|
||||||
|
// Activate and deactivate
|
||||||
|
var controlWindow_main = document.createElement('div');
|
||||||
|
controlWindow_main.setAttribute('id','controlWindow_main');
|
||||||
|
controlWindow_main.setAttribute('style','text-align: center;');
|
||||||
|
controlWindow_main.innerHTML = '<br /><br /><a>Main control:<br />';
|
||||||
|
if (maincontrol) {
|
||||||
|
controlWindow_main.innerHTML += '<span style="color: #008000;">active</span>';
|
||||||
|
} else {
|
||||||
|
controlWindow_main.innerHTML += '<span style="color: #BF0000;">inactive</span>';
|
||||||
|
}
|
||||||
|
controlWindow_main.innerHTML += '</a>';
|
||||||
|
controlWindow_main.addEventListener("click", function() { maincontrol = !maincontrol; refreshControlWindow();}, true);
|
||||||
|
controlWindow.appendChild(controlWindow_main);
|
||||||
|
}
|
82
VDex_Project_Battle_Tool.user.js
Executable file
82
VDex_Project_Battle_Tool.user.js
Executable file
|
@ -0,0 +1,82 @@
|
||||||
|
// ==UserScript==
|
||||||
|
// @name VDex Project Battle Tool
|
||||||
|
// @namespace http://www.enbewe.de/vdex/
|
||||||
|
// @description Removes Confirmation Dialog
|
||||||
|
// @include http://vdexproject.net/battle.php?*
|
||||||
|
// @include http://vdexproject.net/talk.php?npc=registeel
|
||||||
|
// @version 0.1
|
||||||
|
// ==/UserScript==
|
||||||
|
|
||||||
|
unsafeWindow.chspoke = function(what,pid) {
|
||||||
|
var params = "mode=registeel&pid="+pid;
|
||||||
|
var target = "ajax9.php";
|
||||||
|
var xmlhttp = unsafeWindow.createXmlhttp();
|
||||||
|
xmlhttp.onreadystatechange = function () {
|
||||||
|
if ( xmlhttp.readyState == 1 ) {
|
||||||
|
unsafeWindow.npctalktext.innerHTML = "Please stand by.<br /><img src=\"http://zangoose.vdexproject.net/loading.gif\" alt=\"Loading...\" />";
|
||||||
|
unsafeWindow.playertalktext.className = "hidden";
|
||||||
|
}
|
||||||
|
if ( xmlhttp.readyState == 4 ) {
|
||||||
|
unsafeWindow.hiddendiv.innerHTML = xmlhttp.responseText;
|
||||||
|
var anpc = document.getElementById("ajaxnpc");
|
||||||
|
if ( anpc ) {
|
||||||
|
unsafeWindow.npctalktext.innerHTML = anpc.innerHTML;
|
||||||
|
unsafeWindow.playertalktext.innerHTML = playertalkback.innerHTML;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
alert (xmlhttp.responseText);
|
||||||
|
unsafeWindow.npctalktext.innerHTML = "That seems to have been unsuccessful.";
|
||||||
|
unsafeWindow.playertalktext.innerHTML = playertalkback.innerHTML;
|
||||||
|
}
|
||||||
|
playertalktext.className = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
unsafeWindow.sendRequest(xmlhttp, target, params);
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafeWindow.usemove = function(bid, move, mname) {
|
||||||
|
if ( unsafeWindow.midajax ) { return; }
|
||||||
|
var loaddiv = document.getElementById("loading");
|
||||||
|
var maindiv = document.getElementById("stuff");
|
||||||
|
var blog = document.getElementById("battlelog");
|
||||||
|
var scr = blog.scrollTop;
|
||||||
|
var target = "bajax.php";
|
||||||
|
var params = "mode=move&bid="+bid+"&move="+move;
|
||||||
|
unsafeWindow.midajax = true;
|
||||||
|
var xmlhttp = unsafeWindow.createXmlhttp();
|
||||||
|
xmlhttp.onreadystatechange = function () {
|
||||||
|
if ( xmlhttp.readyState ==1 ) {
|
||||||
|
loaddiv.innerHTML = '<img src="http://zangoose.vdexproject.net/loading.gif" alt="Loading..." />';
|
||||||
|
}
|
||||||
|
if ( xmlhttp.readyState == 4 ) {
|
||||||
|
loaddiv.innerHTML = "";
|
||||||
|
maindiv.innerHTML = xmlhttp.responseText;
|
||||||
|
var blog = document.getElementById("battlelog");
|
||||||
|
blog.scrollTop = scr+1000;
|
||||||
|
unsafeWindow.midajax = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
unsafeWindow.sendRequest(xmlhttp, target, params);
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafeWindow.cancel = function(bid) {
|
||||||
|
if ( unsafeWindow.midajax ) { return; }
|
||||||
|
var loaddiv = document.getElementById("loading");
|
||||||
|
var maindiv = document.getElementById("stuff");
|
||||||
|
var target = "bajax.php";
|
||||||
|
var params = "mode=end&bid="+bid;
|
||||||
|
unsafeWindow.midajax = true;
|
||||||
|
var xmlhttp = unsafeWindow.createXmlhttp();
|
||||||
|
xmlhttp.onreadystatechange = function () {
|
||||||
|
if ( xmlhttp.readyState ==1 ) {
|
||||||
|
loaddiv.innerHTML = '<img src="http://zangoose.vdexproject.net/loading.gif" alt="Loading..." />';
|
||||||
|
maindiv.innerHTML = "";
|
||||||
|
}
|
||||||
|
if ( xmlhttp.readyState == 4 ) {
|
||||||
|
loaddiv.innerHTML = "";
|
||||||
|
maindiv.innerHTML = xmlhttp.responseText;
|
||||||
|
unsafeWindow.midajax = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
unsafeWindow.sendRequest(xmlhttp, target, params);
|
||||||
|
}
|
43
VDex_Project_Berry_Timer.user.js
Executable file
43
VDex_Project_Berry_Timer.user.js
Executable file
|
@ -0,0 +1,43 @@
|
||||||
|
// ==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+'<br>';
|
||||||
|
} else {
|
||||||
|
berryTimerDiv.innerHTML += 'Slot '+(i+1)+': Nicht definiert<br>';
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
116
VDex_Project_Dungeon_Enemy_Indicator.user.js
Executable file
116
VDex_Project_Dungeon_Enemy_Indicator.user.js
Executable file
|
@ -0,0 +1,116 @@
|
||||||
|
// ==UserScript==
|
||||||
|
// @name VDex Project Dungeon Enemy Indicator
|
||||||
|
// @namespace http://www.enbewe.de/vdex
|
||||||
|
// @description Indicates whether an enemy is killable or not
|
||||||
|
// @include http://vdexproject.net/dungeon.php?mode=navigate*
|
||||||
|
// @version 0.1
|
||||||
|
// ==/UserScript==
|
||||||
|
|
||||||
|
function handleResponse(response) {
|
||||||
|
var rege;
|
||||||
|
var room = document.getElementById("thisroom");
|
||||||
|
|
||||||
|
// Prepare user stats
|
||||||
|
var playdata = document.getElementById('yourdata').innerHTML;
|
||||||
|
rege = /HP.(\d+)/;
|
||||||
|
rege.exec(playdata);
|
||||||
|
var ownHP = parseInt(RegExp.$1);
|
||||||
|
rege = /ATTACK:.(\d+).\(.(\d+)\)/;
|
||||||
|
rege.exec(playdata);
|
||||||
|
var ownAtt = parseInt(RegExp.$1)+parseInt(RegExp.$2);
|
||||||
|
rege = /DEFENSE:\s(\d+)\s\(.(\d+)/;
|
||||||
|
rege.exec(playdata);
|
||||||
|
var ownDef = parseInt(RegExp.$1)+parseInt(RegExp.$2);
|
||||||
|
|
||||||
|
// Test for enemies
|
||||||
|
rege = /There\sare\sENEMIES\sroaming\sthe\sroom/;
|
||||||
|
if (rege.test(room.innerHTML)) {
|
||||||
|
var snapResults = document.evaluate('//span[starts-with(@id,"enemyinfo")]', document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
|
||||||
|
for (var i = snapResults.snapshotLength - 1; i >= 0; i--) {
|
||||||
|
var elm = snapResults.snapshotItem(i);
|
||||||
|
|
||||||
|
rege = /HP:.(\d+);.ATTACK:.(\d+);.DEFENSE:.(\d+)/;
|
||||||
|
rege.exec(elm.innerHTML);
|
||||||
|
var enemyHP = parseInt(RegExp.$1);
|
||||||
|
var enemyAtt = parseInt(RegExp.$2);
|
||||||
|
var enemyDef = parseInt(RegExp.$3);
|
||||||
|
|
||||||
|
var ownDmg = ownAtt - enemyDef;
|
||||||
|
if (ownDmg < 1) { ownDmg = 1; }
|
||||||
|
|
||||||
|
var enemyDmg = enemyAtt - ownDef;
|
||||||
|
if (enemyDmg < 1) { enemyDmg = 1; }
|
||||||
|
|
||||||
|
if (ownDmg >= enemyHP) {
|
||||||
|
elm.innerHTML += '<b>One Hit Kill!</b><br>';
|
||||||
|
} else if (enemyHP/ownDmg <= ownHP/enemyDmg) {
|
||||||
|
elm.innerHTML += '<b>You will win!</b><br>';
|
||||||
|
} else {
|
||||||
|
elm.innerHTML += '<b>You will fail or need to heal!</b><br>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Setting up ajax capture
|
||||||
|
var OldXHR = unsafeWindow.XMLHttpRequest;
|
||||||
|
var NewXHR = function() {
|
||||||
|
var self = this;
|
||||||
|
var actualXHR = new OldXHR();
|
||||||
|
|
||||||
|
this.ononreadystatechange = function() {
|
||||||
|
if (self.readyState == 4) {
|
||||||
|
setTimeout(function() {
|
||||||
|
handleResponse(self.responseText)
|
||||||
|
},1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.requestHeaders = "";
|
||||||
|
this.requestBody = "";
|
||||||
|
|
||||||
|
// emulate methods from regular XMLHttpRequest object
|
||||||
|
this.open = function(a, b, c, d, e) {
|
||||||
|
self.openMethod = a.toUpperCase();
|
||||||
|
self.openURL = b;
|
||||||
|
if (self.onopen != null && typeof(self.onopen) == "function") { self.onopen(a,b,c,d,e); }
|
||||||
|
return actualXHR.open(a,b,c,d,e);
|
||||||
|
}
|
||||||
|
this.send = function(a) {
|
||||||
|
if (self.onsend != null && typeof(this.onsend) == "function") { self.onsend(a); }
|
||||||
|
self.requestBody += a;
|
||||||
|
return actualXHR.send(a);
|
||||||
|
}
|
||||||
|
this.setRequestHeader = function(a, b) {
|
||||||
|
if (self.onsetrequestheader != null && typeof(self.onsetrequestheader) == "function") { self.onsetrequestheader(a, b); }
|
||||||
|
self.requestHeaders += a + ":" + b + "\r\n";
|
||||||
|
return actualXHR.setRequestHeader(a, b);
|
||||||
|
}
|
||||||
|
this.getRequestHeader = function() { return actualXHR.getRequestHeader(); }
|
||||||
|
this.getResponseHeader = function(a) { return actualXHR.getResponseHeader(a); }
|
||||||
|
this.getAllResponseHeaders = function() { return actualXHR.getAllResponseHeaders(); }
|
||||||
|
this.abort = function() { return actualXHR.abort(); }
|
||||||
|
this.addEventListener = function(a, b, c) { alert("not implemented yet"); }
|
||||||
|
this.dispatchEvent = function(e) { alert("not implemented yet"); }
|
||||||
|
this.openRequest = function(a, b, c, d, e) { alert("not implemented yet"); }
|
||||||
|
this.overrideMimeType = function(e) { alert("not implemented yet"); }
|
||||||
|
this.removeEventListener = function(a, b, c) { alert("not implemented yet"); }
|
||||||
|
|
||||||
|
|
||||||
|
// emulate callbacks from regular XMLHttpRequest object
|
||||||
|
actualXHR.onreadystatechange = function() {
|
||||||
|
|
||||||
|
// copy properties back from the actual XHR to the wrapper
|
||||||
|
self.readyState = actualXHR.readyState;
|
||||||
|
try { self.status = actualXHR.status; } catch (e) {}
|
||||||
|
try { self.responseText = actualXHR.responseText; } catch (e) {}
|
||||||
|
try { self.statusText = actualXHR.statusText; } catch (e) {}
|
||||||
|
try { self.responseXML = actualXHR.responseXML; } catch (e) {}
|
||||||
|
try { if (self.ononreadystatechange != null && typeof(self.ononreadystatechange) == "function") { self.ononreadystatechange(); } } catch (e) {}
|
||||||
|
|
||||||
|
if (self.onreadystatechange != null && typeof(self.onreadystatechange) == "function") { return self.onreadystatechange(); }
|
||||||
|
}
|
||||||
|
actualXHR.onerror = function(e) { if (self.onerror != null) { return self.onerror(e); } }
|
||||||
|
actualXHR.onload = function(e) { if (self.onload != null) { return self.onload(e); } }
|
||||||
|
actualXHR.onprogress = function(e) { if (self.onprogress != null) { return self.onprogress(e); } }
|
||||||
|
}
|
||||||
|
unsafeWindow.XMLHttpRequest = NewXHR;
|
45
VDex_Project_Mark_all_pokemon_as_private.user.js
Executable file
45
VDex_Project_Mark_all_pokemon_as_private.user.js
Executable file
|
@ -0,0 +1,45 @@
|
||||||
|
// ==UserScript==
|
||||||
|
// @name VDex Project Mark all pokemon as private
|
||||||
|
// @namespace http://www.enbewe.de/vdex/
|
||||||
|
// @include http://vdexproject.net/pc.php?&mode=sort
|
||||||
|
// @version 1
|
||||||
|
// ==/UserScript==
|
||||||
|
|
||||||
|
// Add private link
|
||||||
|
snapResults = document.evaluate('//table[@class="content"]//table[@class="pcnav"]//div[@class="pc"]/small', document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
|
||||||
|
for (var i = snapResults.snapshotLength - 1; i >= 0; i--) {
|
||||||
|
var elm = snapResults.snapshotItem(i);
|
||||||
|
var boxid = elm.parentNode.getAttribute('id');
|
||||||
|
var rege = /pc(\d+)/;
|
||||||
|
rege.exec(boxid);
|
||||||
|
boxid = RegExp.$1;
|
||||||
|
elm.innerHTML += '<br />[ <span id="bswitch'+boxid+'" class="hlclickable">Mark Public</span> ]';
|
||||||
|
document.getElementById('bswitch'+boxid).addEventListener("click",markPublic, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
function markPublic() {
|
||||||
|
var active = document.evaluate('//table[@class="pcnav"]//div[@class="pc"][not(@style="display: none;")]', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
|
||||||
|
var boxid = active.getAttribute('id');
|
||||||
|
var rege = /pc(\d+)/;
|
||||||
|
rege.exec(boxid);
|
||||||
|
boxid = RegExp.$1;
|
||||||
|
|
||||||
|
for (var i = 1; i<=42; i++) {
|
||||||
|
var text = document.evaluate('//td[@id="box'+boxid+'slot'+i+'"]/img', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.getAttribute('onmouseover');
|
||||||
|
if (text) {
|
||||||
|
rege = /(\d+)/;
|
||||||
|
rege.exec(text);
|
||||||
|
text = "mode=public&pid="+RegExp.$1;
|
||||||
|
var xmlhttp = new XMLHttpRequest();
|
||||||
|
|
||||||
|
xmlhttp.open("POST", "kadabra/files/ajax/private.php", false);
|
||||||
|
|
||||||
|
xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
|
||||||
|
xmlhttp.setRequestHeader("Content-length", text.length);
|
||||||
|
xmlhttp.setRequestHeader("Connection", "close");
|
||||||
|
|
||||||
|
xmlhttp.send (text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
213
VDex_Project_Pokemon_Tracker.user.js
Executable file
213
VDex_Project_Pokemon_Tracker.user.js
Executable file
|
@ -0,0 +1,213 @@
|
||||||
|
// ==UserScript==
|
||||||
|
// @name VDex Project Pokemon Tracker
|
||||||
|
// @namespace http://www.enbewe.de/vdex/
|
||||||
|
// @description Lets you track pokemon
|
||||||
|
// @include http://vdexproject.net/poke.php*
|
||||||
|
// @include http://vdexproject.net/pokegear.php*
|
||||||
|
// @copyright eNBeWe
|
||||||
|
// @version 0.3
|
||||||
|
// ==/UserScript==
|
||||||
|
(function (){
|
||||||
|
var page = window.location.pathname
|
||||||
|
if (page == "/pokegear.php" || page == "/pokegear.php#info") {
|
||||||
|
|
||||||
|
// Fetch anchor
|
||||||
|
var anchor = document.evaluate('//table[@class="content"]/tbody',document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
|
||||||
|
|
||||||
|
// Create and place row for tracking plugin
|
||||||
|
var elmContentRow = document.createElement('tr');
|
||||||
|
anchor.appendChild(elmContentRow);
|
||||||
|
|
||||||
|
// Create and place cell with heading
|
||||||
|
var elmContentCell = document.createElement('td');
|
||||||
|
elmContentRow.appendChild(elmContentCell);
|
||||||
|
elmContentCell.setAttribute("id","trackingHeader");
|
||||||
|
elmContentCell.setAttribute("style","vertical-align: top;");
|
||||||
|
elmContentCell.setAttribute("colspan","2");
|
||||||
|
elmContentCell.innerHTML = '<b>Tracked Pokemon:</b><br>';
|
||||||
|
|
||||||
|
// Place link to load the tracked pokemon
|
||||||
|
var loadTrackedLink = document.createElement('small');
|
||||||
|
loadTrackedLink.setAttribute("id","trackerLinkSmall");
|
||||||
|
loadTrackedLink.innerHTML = '[ <span class="hlclickable">Load tracked Pokemon</span> ]';
|
||||||
|
loadTrackedLink.addEventListener("click", function(){loadTracked();}, true);
|
||||||
|
elmContentCell.appendChild(loadTrackedLink);
|
||||||
|
} else if (page == "/poke.php") {
|
||||||
|
|
||||||
|
// Get PokeID of active pokemon
|
||||||
|
var pokeID = getUrlParam('id');
|
||||||
|
|
||||||
|
// Fetch anchor
|
||||||
|
var anchor = document.getElementById('infopoke');
|
||||||
|
|
||||||
|
// Create and place link to toggle tracking
|
||||||
|
var elmTrackerLink = document.createElement('small');
|
||||||
|
elmTrackerLink.innerHTML = '[ <span class="hlclickable">Toggle pokemon tracking</span> ]';
|
||||||
|
elmTrackerLink.addEventListener("click", function(){toggleTracking(pokeID);}, true);
|
||||||
|
anchor.parentNode.insertBefore(elmTrackerLink, anchor.nextSibling);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Load trcked pokemon
|
||||||
|
function loadTracked() {
|
||||||
|
|
||||||
|
// Fetch anchor
|
||||||
|
var trackedLink = document.getElementById('trackerLinkSmall');
|
||||||
|
var anchor = trackedLink.parentNode;
|
||||||
|
|
||||||
|
// Remove Link
|
||||||
|
anchor.removeChild(trackedLink);
|
||||||
|
|
||||||
|
// Get list of tracked pokemon
|
||||||
|
var pokelist = GM_getValue('track','');
|
||||||
|
if (pokelist == '' || pokelist == ' '){
|
||||||
|
// List is empty -> display message
|
||||||
|
var trackerMsg = document.createElement('small');
|
||||||
|
trackerMsg.innerHTML = 'No pokemon are being tracked';
|
||||||
|
anchor.appendChild(trackerMsg);
|
||||||
|
} else {
|
||||||
|
// Convert List to Array
|
||||||
|
var Pokemon = pokelist.split(' ');
|
||||||
|
|
||||||
|
// Prepare table
|
||||||
|
var trackedTable = document.createElement('table');
|
||||||
|
trackedTable.setAttribute('id','trackingTable');
|
||||||
|
anchor.appendChild(trackedTable);
|
||||||
|
|
||||||
|
// Load data for tracked pokemon
|
||||||
|
for (var i = 0; i < Pokemon.length; i++) {
|
||||||
|
GM_xmlhttpRequest({
|
||||||
|
method: "GET",
|
||||||
|
url: "http://vdexproject.net/poke.php?&id="+Pokemon[i],
|
||||||
|
onload: function(response){
|
||||||
|
addPokemonToView(response);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Helper function to add a loaded Pokemon to the view
|
||||||
|
function addPokemonToView(response) {
|
||||||
|
// Fetch anchor
|
||||||
|
var anchor = document.getElementById('trackingTable');
|
||||||
|
|
||||||
|
var textToInsert;
|
||||||
|
var activeRow;
|
||||||
|
|
||||||
|
// Fetch pokemon id
|
||||||
|
var regex = /id=(\d*)/;
|
||||||
|
regex.exec(response.finalUrl);
|
||||||
|
var pokeid = RegExp.$1;
|
||||||
|
|
||||||
|
if (response.responseText.search(/does\snot\shave\san\sowner\scurrently/) == -1) {
|
||||||
|
// Pokemon has owner
|
||||||
|
|
||||||
|
// Parse response
|
||||||
|
var parser = new DOMParser();
|
||||||
|
var data = parser.parseFromString(response.responseText, "text/html");
|
||||||
|
|
||||||
|
// Store data for cell entry
|
||||||
|
var celldata = data.evaluate('//table[@id="infopoke"]/tbody/tr[1]',data, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
|
||||||
|
textToInsert = '<table><tr>'+celldata.innerHTML+'</tr></table><div style="text-align: center;"><small>( <a href="http://vdexproject.net/poke.php?&id='+pokeid+'">more info</a> )</small></div>';
|
||||||
|
} else {
|
||||||
|
textToInsert = '<div style="text-align: center;">Pokemon has currently no owner!</div>';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get number of existing cells
|
||||||
|
var existingCellsCount = document.evaluate('//table[@id="trackingTable"]/tr/td', document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null).snapshotLength;
|
||||||
|
|
||||||
|
// Determine side where to add the new cell
|
||||||
|
if (existingCellsCount % 2 == 1) {
|
||||||
|
activeRow = document.evaluate('//table[@id="trackingTable"]/tr[last()]', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
|
||||||
|
} else {
|
||||||
|
activeRow = document.createElement('tr');
|
||||||
|
anchor.appendChild(activeRow);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create new cell
|
||||||
|
var elmNewCell = document.createElement('td');
|
||||||
|
elmNewCell.setAttribute('style','padding: 20px; border: 2px solid grey;');
|
||||||
|
elmNewCell.innerHTML = textToInsert;
|
||||||
|
|
||||||
|
// Add removal link
|
||||||
|
var elmRemovalLink = document.createElement('small');
|
||||||
|
elmRemovalLink.innerHTML = '[ <span class="hlclickable">Toggle pokemon tracking</span> ]';
|
||||||
|
elmRemovalLink.addEventListener("click", function(){toggleTracking(pokeid);}, true);
|
||||||
|
var elmRemovalDiv = document.createElement('div');
|
||||||
|
elmRemovalDiv.setAttribute('style','text-align: center;');
|
||||||
|
elmRemovalDiv.appendChild(elmRemovalLink);
|
||||||
|
elmNewCell.appendChild(elmRemovalDiv);
|
||||||
|
activeRow.appendChild(elmNewCell);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Helper function to toggle tracking of pokemon
|
||||||
|
function toggleTracking(pokemonID) {
|
||||||
|
|
||||||
|
// Get list of tracked pokemon
|
||||||
|
var getter = GM_getValue('track','');
|
||||||
|
|
||||||
|
// If the list is empty set active pokemon as tracked
|
||||||
|
if (getter == '' || getter == ' ') {
|
||||||
|
GM_setValue('track', pokemonID);
|
||||||
|
alert('Tracking this pokemon');
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Parse list
|
||||||
|
var Pokemon = getter.split(' ');
|
||||||
|
|
||||||
|
// Check if pokemon is already tracked
|
||||||
|
if (contains(Pokemon, pokemonID)) {
|
||||||
|
// Remove pokemon from array
|
||||||
|
var Pokemon_neu = new Array();
|
||||||
|
for (var i = 0; i < Pokemon.length; i++) {
|
||||||
|
if (Pokemon[i] == pokemonID) Pokemon[i] = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Strip double spaces
|
||||||
|
var trackString = Pokemon.join(' ');
|
||||||
|
trackString = trackString.replace(/\s\s/g,' ');
|
||||||
|
trackString = trackString.replace(/^\s/,'');
|
||||||
|
trackString = trackString.replace(/\s$/,'');
|
||||||
|
|
||||||
|
// Save new list
|
||||||
|
GM_setValue('track', trackString);
|
||||||
|
alert('Removed pokemon from tracking');
|
||||||
|
} else {
|
||||||
|
// Add pokemon to list
|
||||||
|
Pokemon.push(pokemonID);
|
||||||
|
var trackString = Pokemon.join(' ');
|
||||||
|
trackString = trackString.replace(/\s\s/g,' ');
|
||||||
|
trackString = trackString.replace(/^\s/,'');
|
||||||
|
trackString = trackString.replace(/\s$/,'');
|
||||||
|
|
||||||
|
// Save new list
|
||||||
|
GM_setValue('track', trackString);
|
||||||
|
alert('Tracking this pokemon');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Helper function to check if an array contains a given element
|
||||||
|
function contains(a, obj) {
|
||||||
|
for (var i = 0; i < a.length; i++) {
|
||||||
|
if (a[i] === obj) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Helper function to parse url parameters
|
||||||
|
function getUrlParam(name) {
|
||||||
|
name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
|
||||||
|
var regexS = "[\\?&]"+name+"=([^&#]*)";
|
||||||
|
var regex = new RegExp(regexS);
|
||||||
|
var results = regex.exec(window.location.href);
|
||||||
|
if ( results == null ) {
|
||||||
|
return "";
|
||||||
|
} else {
|
||||||
|
return results[1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})();
|
56
VDex_Project_Refresh_Counter.user.js
Executable file
56
VDex_Project_Refresh_Counter.user.js
Executable file
|
@ -0,0 +1,56 @@
|
||||||
|
// ==UserScript==
|
||||||
|
// @name VDex Project Refresh Counter
|
||||||
|
// @namespace http://www.enbewe.de/vdex
|
||||||
|
// @include http://vdexproject.net/map.php*
|
||||||
|
// @version 0.1
|
||||||
|
// ==/UserScript==
|
||||||
|
|
||||||
|
var cnt = GM_getValue('refreshCnt',0);
|
||||||
|
|
||||||
|
var displayDiv = document.createElement('div');
|
||||||
|
displayDiv.setAttribute('id','displayDiv');
|
||||||
|
displayDiv.setAttribute('style','width:140px; height:50px; position: fixed; bottom: 10px; right: 10px; background: #232323; border: 3px solid grey; padding: 10px; text-align:center;');
|
||||||
|
document.getElementById('login').parentNode.appendChild(displayDiv);
|
||||||
|
refreshDisplay();
|
||||||
|
|
||||||
|
|
||||||
|
//Setting up refresh capture
|
||||||
|
var oldRefresh = unsafeWindow.refresh;
|
||||||
|
var newRefresh = function() {
|
||||||
|
cnt++;
|
||||||
|
setTimeout(function() {GM_setValue('refreshCnt',cnt);}, 1);
|
||||||
|
refreshDisplay();
|
||||||
|
oldRefresh();
|
||||||
|
}
|
||||||
|
unsafeWindow.refresh = newRefresh;
|
||||||
|
|
||||||
|
var oldFishRefresh = unsafeWindow.fishrefresh;
|
||||||
|
var newFishRefresh = function(item) {
|
||||||
|
cnt++;
|
||||||
|
setTimeout(function() {GM_setValue('refreshCnt',cnt);}, 1);
|
||||||
|
refreshDisplay();
|
||||||
|
oldFishRefresh(item);
|
||||||
|
}
|
||||||
|
unsafeWindow.fishrefresh = newFishRefresh;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function refreshDisplay() {
|
||||||
|
displayDiv.innerHTML = '<b>Refresh Counter:</b><br>';
|
||||||
|
displayDiv.innerHTML += cnt;
|
||||||
|
displayDiv.innerHTML += '<br>';
|
||||||
|
var resetSpan = document.createElement('a');
|
||||||
|
resetSpan.setAttribute('class','hlclickable');
|
||||||
|
resetSpan.innerHTML = '(Reset Counter)';
|
||||||
|
displayDiv.appendChild(resetSpan);
|
||||||
|
resetSpan.addEventListener("click", resetCounter, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function resetCounter() {
|
||||||
|
cnt = 0;
|
||||||
|
setTimeout(function() {GM_setValue('refreshCnt',cnt);}, 1);
|
||||||
|
refreshDisplay();
|
||||||
|
}
|
23
VDex_Project_Search_for_Pokemon.user.js
Executable file
23
VDex_Project_Search_for_Pokemon.user.js
Executable file
|
@ -0,0 +1,23 @@
|
||||||
|
// ==UserScript==
|
||||||
|
// @name VDex Project Search for Pokemon
|
||||||
|
// @namespace http://www.enbewe.de/vdex
|
||||||
|
// @description Lets you search a Pokemon from its Pokedex page
|
||||||
|
// @include http://vdexproject.net/pokedex.php?n=*
|
||||||
|
// @version 0.3
|
||||||
|
// ==/UserScript==
|
||||||
|
|
||||||
|
|
||||||
|
var form = document.evaluate('//form[@action="mapdex.php"]', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
|
||||||
|
var btn = document.evaluate('//form[@action="mapdex.php"]/input[@type="submit"]', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
|
||||||
|
if (form) {
|
||||||
|
form.removeChild(btn);
|
||||||
|
var submitLink = document.createElement('a');
|
||||||
|
submitLink.setAttribute('class','hlclickable');
|
||||||
|
submitLink.innerHTML = '<img src="http://zangoose.vdexproject.net/dex.png" alt="Search this Pokemon in Mapdex">';
|
||||||
|
submitLink.addEventListener("click",function(){form.submit();}, true);
|
||||||
|
form.appendChild(submitLink);
|
||||||
|
|
||||||
|
var spriteBtn = document.evaluate('//a/input[@class="btn"]', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.parentNode;
|
||||||
|
spriteBtn.innerHTML = '<img src="http://zangoose.vdexproject.net/gallery.png" alt="View Sprite Gallery">'
|
||||||
|
|
||||||
|
}
|
74
VDex_Project_Timezone_Changer.user.js
Executable file
74
VDex_Project_Timezone_Changer.user.js
Executable file
|
@ -0,0 +1,74 @@
|
||||||
|
// ==UserScript==
|
||||||
|
// @name VDex Project Timezone Changer
|
||||||
|
// @namespace Http://www.enbewe.de/vdex
|
||||||
|
// @description Lets you change your timezone from the map
|
||||||
|
// @include http://vdexproject.net/map.php*
|
||||||
|
// @version 0.3
|
||||||
|
// ==/UserScript==
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
var anchor = document.evaluate('//div[@id="footer"]/span',document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
|
||||||
|
|
||||||
|
var timezoneDiv = document.createElement('div');
|
||||||
|
timezoneDiv.setAttribute('id','timezoneDiv');
|
||||||
|
timezoneDiv.innerHTML = 'Zeit: ';
|
||||||
|
anchor.parentNode.insertBefore(timezoneDiv,anchor);
|
||||||
|
|
||||||
|
|
||||||
|
var timezoneLinkm1 = document.createElement('a');
|
||||||
|
timezoneLinkm1.setAttribute('class','clickable');
|
||||||
|
timezoneLinkm1.innerHTML = '(-1)';
|
||||||
|
timezoneLinkm1.addEventListener("click",function(){changeTimezone(-1)}, true);
|
||||||
|
timezoneDiv.appendChild(timezoneLinkm1);
|
||||||
|
|
||||||
|
|
||||||
|
var timezoneLink1 = document.createElement('a');
|
||||||
|
timezoneLink1.setAttribute('class','clickable');
|
||||||
|
timezoneLink1.innerHTML = '(+1)';
|
||||||
|
timezoneLink1.addEventListener("click",function(){changeTimezone(1)}, true);
|
||||||
|
timezoneDiv.appendChild(timezoneLink1);
|
||||||
|
|
||||||
|
|
||||||
|
function changeTimezone(amount) {
|
||||||
|
|
||||||
|
var xmlhttp = new XMLHttpRequest();
|
||||||
|
xmlhttp.open("GET","/forum/ucp.php?i=165",false);
|
||||||
|
xmlhttp.send();
|
||||||
|
|
||||||
|
var parser = new DOMParser();
|
||||||
|
var data = parser.parseFromString(xmlhttp.responseText, "text/html");
|
||||||
|
|
||||||
|
var params = '';
|
||||||
|
|
||||||
|
var snapResults = data.evaluate("//form//input", data, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
|
||||||
|
for (var i = snapResults.snapshotLength - 1; i >= 0; i--) {
|
||||||
|
var elm = snapResults.snapshotItem(i);
|
||||||
|
if (elm.getAttribute('type') != 'reset' && (elm.getAttribute('type') != 'radio' || elm.getAttribute('checked') == 'checked')) {
|
||||||
|
params += elm.getAttribute('name')+'='+elm.getAttribute('value')+'&';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var snapResult = data.evaluate('//form//select[@id="tz"]/option[@selected="selected"]', data, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
|
||||||
|
var timezone = parseInt(snapResult.getAttribute('value'));
|
||||||
|
|
||||||
|
params += 'tz='+(timezone+amount);
|
||||||
|
|
||||||
|
var url = "/forum/ucp.php?i=prefs&mode=personal";
|
||||||
|
|
||||||
|
var http = new XMLHttpRequest();
|
||||||
|
http.open("POST", url, false);
|
||||||
|
|
||||||
|
//Send the proper header information along with the request
|
||||||
|
http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
|
||||||
|
http.setRequestHeader("Content-length", params.length);
|
||||||
|
http.setRequestHeader("Connection", "close");
|
||||||
|
|
||||||
|
http.send(params);
|
||||||
|
|
||||||
|
if (http.responseText.search(/preferences\shave\sbeen\supdated/)) {
|
||||||
|
window.location.reload();
|
||||||
|
} else {
|
||||||
|
alert('Fail:\n'+http.responseText);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue