-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathshow_precise_last_action.user.js
More file actions
35 lines (33 loc) · 1.46 KB
/
Copy pathshow_precise_last_action.user.js
File metadata and controls
35 lines (33 loc) · 1.46 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
// ==UserScript==
// @name Torn: Profile: Show precise last action
// @namespace lugburz.profile.show_precise_last_action
// @version 0.1
// @description Show precise last action on profiles.
// @author Lugburz [2386297]
// @match https://www.torn.com/profiles.php?XID=*
// @match https://www.torn.com/profiles.php?NID=*
// @require https://github.com/f2404/torn-userscripts/raw/7401f7e0c5b2dfaaa47988684ca518316750520e/lib/lugburz_lib.js
// @updateURL https://github.com/f2404/torn-userscripts/raw/master/show_precise_last_action.user.js
// @downloadURL https://github.com/f2404/torn-userscripts/raw/master/show_precise_last_action.user.js
// @grant none
// @run-at document-body
// ==/UserScript==
function parseLastAction(text) {
try {
const json = JSON.parse(text);
const lastAction = json.basicInformation.lastAction.seconds !== 'Unknown' ? secondsToDhms(json.basicInformation.lastAction.seconds) + ' ago' : json.basicInformation.lastAction.seconds;
if ($('ul.info-table').size() > 0) {
$('ul.info-table > li').each((i, item) => {
if ($(item).find('span:contains("Last action")').size() > 0) {
$(item).find('div.user-info-value > span').text(lastAction);
}
});
}
} catch (e) {
console.log(e);
}
}
ajax((page, xhr) => {
if (page !== 'profiles') return;
parseLastAction(xhr.responseText);
});