0% found this document useful (0 votes)
17K views4 pages

Script TG

This user script monitors resource levels and alerts the player when certain thresholds are reached for buying or selling resources. It uses local storage to save alert threshold settings and checks resource levels at regular intervals, speaking alerts using the speech synthesis API when conditions are met. The script adds inputs and selects to the premium exchange interface to configure alert levels and actions for wood, stone, and iron resources.

Uploaded by

Alin Manciu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17K views4 pages

Script TG

This user script monitors resource levels and alerts the player when certain thresholds are reached for buying or selling resources. It uses local storage to save alert threshold settings and checks resource levels at regular intervals, speaking alerts using the speech synthesis API when conditions are met. The script adds inputs and selects to the premium exchange interface to configure alert levels and actions for wood, stone, and iron resources.

Uploaded by

Alin Manciu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

// ==UserScript==

// @name pp alert
// @author Chinezu
// @version 1.1
// @description pp alert
// @match *://*[Link]?*screen=market*
// @match [Link]
// @match [Link]
// @match [Link]
// @grant [Link]
// @grant [Link]
// ==/UserScript==

javascript: {
(function($, adapter) {
var data = [Link]() || [Link]({
wood: {
alert: 64,
action: "none"
},
stone: {
alert: 64,
action: "none"
},
iron: {
alert: 64,
action: "none"
}
}).Get();
var type;
for (type in data) {
/** @type {string} */
data[type].action = "none";
}
var _post = function(name) {
var obj = {
ro: {
alert: "Alerte",
sell: "vinde",
buy: "cumpara",
none: "nimic"
},
en: {
alert: "Alert",
sell: "sell",
buy: "buy",
none: "none"
}
};
return function(i) {
return name in obj ? obj[name][i] : [Link][i];
};
}(game_data.market); /** @type {boolean} */
var m = false; /** * @param {!Object} msg * @param {!
Object} text * @return {undefined} */
var init = function(msg, text) {
if (!m) {
msg = new SpeechSynthesisUtterance(msg); /** @type {number} */
[Link] = 1.5; /** @type {number} */
[Link] = 2; /** @type {string} */
[Link] = "en-US";
[Link]("start", function(a) {
/** @type {boolean} */
m = true;
});
[Link]("end", function(a) {
/** @type {boolean} */
m = false;
});
[Link](msg);
}
}; /** * @return {?} */
var promptConfirmation = function() {
return new Promise(function(saveNotifs, canCreateDiscussions) {
[Link]("market", {
ajax: "exchange_data"
}, function(notifications) {
saveNotifs(notifications);
});
});
};
[Link](".premium-
exchange").querySelector("tbody").appendChild(function(label) {
[Link]($("th", {
innerText: _post("alert"),
style: {
textAlign: "left"
}
}));
["wood", "stone", "iron"].forEach(function(probe_name) {
var group = $("input", {
type: "number",
min: 64,
dataset: {
type: probe_name
},
value: data[probe_name].alert,
oninput: function() {
/** @type {number} */
data[[Link]].alert = 1 * [Link];
[Link](data);
}
}); /** @type
{(ObjectPropertyDescriptor<[Link]>|undefined)} */
var config =
[Link]([Link], "value"); /** @type
{function(?): undefined} */
var setp = [Link]; /** * @param {?} mymuted
* @return {undefined} */
[Link] = function(mymuted) {
[Link](this, "value", {
set: setp
});
[Link] = data[probe_name].alert;
[Link](this, "value", config);
};
[Link](group, "value", config);
var node = $("select", {
dataset: {
type: probe_name
},
onchange: function() {
data[[Link]].action =
[Link][[Link]].[Link];
}
});
[Link]($("option", {
dataset: {
action: "none"
},
text: _post("none")
}));
[Link]($("option", {
dataset: {
action: "sell"
},
text: _post("sell")
}));
[Link]($("option", {
dataset: {
action: "buy"
},
text: _post("buy")
}));
[Link]($("td", {
className: "center"
}).appendChild(group).[Link](node).parentNode);
});
return label;
}($("tr")));
setInterval(function() {
promptConfirmation().then(function(d) {
/** @type {!Object} */
[Link] = d;
[Link]();
var dp = [Link];
var key;
for (key in data) {
var encodedKeyOrRange =
[Link](key);
if ("buy" == data[key].action) {
let message = `${game_data.[Link]} buy`;
if (encodedKeyOrRange >= data[key].alert) {
init(message, key);
}
} else {
let message = `${game_data.[Link]} sell`;
if ("sell" == data[key].action && encodedKeyOrRange <
data[key].alert && 1 <= [Link][key] - [Link][key]) {
init(message, key);
}
}
}
});
}, 1200);
})(function(node, styles) {
/** @type {!Element} */
node = [Link](node);
if (styles) {
var property;
for (property in styles) {
if (property in node) {
if ("object" != typeof styles[property]) {
node[property] = styles[property];
} else {
var i;
for (i in styles[property]) {
node[property][i] = styles[property][i];
}
}
}
}
}
return node;
}, function(dbName) {
return {
Set: function(data) {
if (data) {
/** @type {string} */
localStorage[dbName] = [Link](data);
} else {
delete localStorage[dbName];
}
return this;
},
Get: function() {
if (void 0 !== localStorage[dbName]) {
return [Link](localStorage[dbName]);
}
}
};
}("resourceAlert"));
};

You might also like