-
Notifications
You must be signed in to change notification settings - Fork 0
/
JunkieHelper.user.js
62 lines (52 loc) · 2.69 KB
/
JunkieHelper.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
60
61
// ==UserScript==
// @name Junkie Helper
// @version 1.0
// @description Retrieves coffee, utilizing sofa & apron
// @author Volcher
// @include http://mush.twinoid.com/
// @downloadURL https://raw.githubusercontent.com/insoln/mush/master/JunkieHelper.user.js
// @grant none
// ==/UserScript==
function getButton(item, string){
var ser = Main.iid2Serial(item) || $("#myInventory").find("li[data-id='"+item+"']").attr("serial"); //iid2Serial doesn't works with own inventory.
var buts = $(".cdActionRepository").find("div[webdata='"+ser+"']:not(.fake):contains('"+string+"') a"); //Gives active buttons of existing item, no additional checks required.
return buts.length==0?null:buts[0];
}
function tryButton(item, string){
var but = getButton(item, string);
if(but !== null){
but.click();
return true;
} else return false;
}
function onlyBeforeCoffee(what){
var coffeeTakenLog = $(".cdChatPack:first div.cdChatLine:contains('It smells like a warm morning on a terrace on Venus. Coffee!')");
var beforeCoffee = coffeeTakenLog.nextAll("div:contains('"+what+"')").length>0;
var afterCoffee = coffeeTakenLog.prevAll("div:contains('"+what+"')").length>0;
return beforeCoffee&&!afterCoffee;
}
function favReport(thread, text){
var coffeeThreadID = $(".cdFavWall .mainsaid:contains('"+thread+"')").parents('.unit').data('k');
if(coffeeThreadID!=undefined) Main.ajaxChat("/wallReply?k=" + coffeeThreadID + "&msg=" + encodeURIComponent(text));
}
function JunkieHelper(){ // Yeah, i know how fucked up execution flow looks...
if($("#input").attr("d_name") != "Refectory") return;
$("#dialog_body:contains('That wasn't supposed to happen. In the heat of the action you hurt yourself...')").parent().find("a").click();
$("#dialog_body:contains('Disgusting... You\'re filthy. (Not like that. Although...)')").parent().find("a").click();
var coffee = getButton("COFFEE_DISPENSER", "Coffee!");
if(coffee !== null){
if(!tryButton("APRON", "Pick up")){
coffee.click();
favReport("Кофе", $('.cycletime').text().replace(/[^DC0-9]/g, "")+": Кофе вытащен");
}
} else {
var curHero = $("h1.who").text().trim();
if (onlyBeforeCoffee(curHero+" wakes up calmly...")) tryButton("SOFA", "Lie Down");
if (onlyBeforeCoffee(curHero+" has picked up the Stainproof Apron.")) tryButton("APRON", "Drop");
}
setTimeout(JunkieHelper, 5000);
}
JunkieHelper(); //Main loop.
setTimeout(function(){
$("#timetomove").find("a")[0].click();
}, Main.tData.timeToCycle - (new Date()).getTime() + Main.tData.clientNow.getTime() + 15000); // Click "Next Cycle" when time comes.