-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSwitchVillages.js
More file actions
95 lines (90 loc) · 3.89 KB
/
SwitchVillages.js
File metadata and controls
95 lines (90 loc) · 3.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
// ==UserScript==
// @name Switch villages
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Script that switches between villages in tribal wars
// @author p0p
// @match https://esp4.guerrastribales.es/game.php?village=*
// @grant none
// ==/UserScript==
(function() {
'use strict';
var villages = [4481,3635];
var nVillages = villages.length;
const llTr = document.createElement("tr"); // Create button called btn as a link
const llTd = document.createElement("td");
const LL = document.getElementById("menu_row2_village"); // Button comes after this element
const btnll = document.createElement("a"); // Create button called btn as a link
btnll.setAttribute("id", "btnLL"); // Set ID of btn
btnll.setAttribute("class", "btn"); // Set ID of btn
btnll.setAttribute("style", "cursor:pointer;"); // Set cursor to pointer
LL.parentNode.insertBefore(btnll, LL.nextElementSibling); // Place btn after menu_row2_village
const tll = document.createTextNode("<-"); // btn has this text
btnll.appendChild(tll); // Append text to btn
const showArrTimeTr = document.createElement("tr"); // Create button called btn as a link
const showArrTimeTd = document.createElement("td");
const pEle = document.getElementById("btnLL"); // Button comes after this element
const btn = document.createElement("a"); // Create button called btn as a link
btn.setAttribute("id", "swv"); // Set ID of btn
btn.setAttribute("class", "btn"); // Set ID of btn
btn.setAttribute("style", "cursor:pointer;"); // Set cursor to pointer
pEle.parentNode.insertBefore(btn, pEle.nextElementSibling); // Place btn after btnLL
const t = document.createTextNode("->"); // btn has this text
btn.appendChild(t); // Append text to btn
btnll.onclick = function() {
var vars = {};
var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {
vars[key] = value;
});
var exit = false;
var i = 0;
/*var URL = document.URL;
URL = URL.replace('https://esp4.guerrastribales.es/game.php?village=','');
URL = URL[0] + URL[1] + URL[2] + URL[3];
if(URL != '4481') {
var url = window.location.toString();
top.location = url.replace(3635, 4481);
}
if(URL != '3635') {
var url2 = window.location.toString();
top.location = url2.replace(4481, 3635);
}*/
while(!exit) {
if(vars["village"]== villages[i%nVillages]) {
var url = window.location.toString();
var a = vars["village"];
top.location = url.replace(a,(villages[(i+1)%nVillages]));
exit = true;
}
i++;
}
}
btn.onclick = function() {
var vars = {};
var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {
vars[key] = value;
});
var exit = false;
var i = 0;
/*var URL = document.URL;
URL = URL.replace('https://esp4.guerrastribales.es/game.php?village=','');
URL = URL[0] + URL[1] + URL[2] + URL[3];
if(URL != '4481') {
var url = window.location.toString();
top.location = url.replace(3635, 4481);
}
if(URL != '3635') {
var url2 = window.location.toString();
top.location = url2.replace(4481, 3635);
}*/
while(!exit) {
if(vars["village"]== villages[i%nVillages]) {
var url = window.location.toString();
var a = vars["village"];
top.location = url.replace(a,(villages[(i+1)%nVillages]));
exit = true;
}
i++;
}
}
})();