forked from tcbasic/tc-greasemonkey
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tcexpressbust.user.js
59 lines (56 loc) · 2.81 KB
/
tcexpressbust.user.js
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
// ==UserScript==
// @name TCExpressBust
// @version 20070718.1
// @author hexkid
// @description Add Express Bust in jail, faction members, and profiles
// @namespace http://hexkid.info/GM/
// @include http://torncity.com/*
// @include http://www.torncity.com/*
// ==/UserScript==
// TCbasic
// add express bust in jail or member list for faction
if (document.location.href.match(/\/(jailview\.php|factions\.php\?step=your&action=members)$/)) {
var LINKs = document.getElementsByTagName('a');
for (var i=0; i<LINKs.length; ++i) {
if (LINKs[i].hasAttribute('href')) {
// add bust link
if (LINKs[i].getAttribute('href').match(/^jail1\.php\?XID=\d+&action=breakout$/)) {
var xid = LINKs[i].getAttribute('href').match(/^jail1\.php\?XID=(\d+)&action=breakout$/)[1];
var expressBust = document.createElement('a');
expressBust.setAttribute('href', 'jail1.php?XID=' + xid + '&action=breakout1');
expressBust.innerHTML = 'Express';
LINKs[i].parentNode.insertBefore(expressBust, LINKs[i].nextSibling);
var separator1 = document.createElement('span');
separator1.innerHTML = ' | ';
LINKs[i].parentNode.insertBefore(separator1, LINKs[i].nextSibling);
if (document.location.href.match(/\/factions/)) {
// add buy link
var expressBuy = document.createElement('a');
expressBuy.setAttribute('href', 'jail1.php?XID=' + xid + '&action=buy');
expressBuy.innerHTML = 'Buy';
LINKs[i].parentNode.insertBefore(expressBuy, LINKs[i]);
// KLUDGE: just added another link to the document.
// i is now wrong
++i;
// i corrected :)
var separator2 = document.createElement('span');
separator2.innerHTML = ' | ';
LINKs[i].parentNode.insertBefore(separator2, LINKs[i]);
}
}
}
}
}
// add buy, bust and express bust in profiles
if (document.location.href.match(/\/profiles\.php\?(action=send&)?XID=\d+&?$/)) {
var xid = document.location.href.match(/\/profiles\.php\?(?:action=send&)?XID=(\d+)&?$/)[1];
if (xid) {
var FONTs = document.getElementsByTagName('font');
for (var i=0; i<FONTs.length; ++i) {
if (FONTs[i].innerHTML.match(/^In jail for (\d+ hrs )?\d+ mins <br>/)) {
var newBustLink = document.createElement('p');
newBustLink.style.marginLeft = '48px';
newBustLink.innerHTML = '[<a href="jail1.php?XID=' + xid + '&action=buy" style="color: brown">Buy</a>] '
+ '[<a href="jail1.php?XID=' + xid + '&action=breakout" style="color: brown">Bust</a> | '
+ '<a href="jail1.php?XID=' + xid + '&action=breakout1" style="color: brown">Express</a>]';
FONTs[i].parentNode.insertBefore(newBustLink, FONTs[i]);