-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathracing_profiles.user.js
More file actions
36 lines (32 loc) · 1.26 KB
/
racing_profiles.user.js
File metadata and controls
36 lines (32 loc) · 1.26 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
// ==UserScript==
// @name Torn: Racing: Links to profiles
// @namespace lugburz.racing.profiles
// @version 0.1.6
// @description Adds links to player profiles to their names in the racing list.
// @author Lugburz
// @match https://www.torn.com/loader.php?sid=racing*
// @match https://www.torn.com/page.php?sid=racing*
// @require https://raw.githubusercontent.com/f2404/torn-userscripts/master/lib/lugburz_lib.js
// @updateURL https://github.com/f2404/torn-userscripts/raw/master/racing_profiles.user.js
// @grant none
// ==/UserScript==
function addLinks() {
const names = $('ul.overview').find('li.name');
names.each(function() {
const parent = $(this).parent().parent();
if (parent.attr('id').startsWith('lbr-')) {
const username = $(this).html().replace('<span>', '').replace('</span>', '');
const user_id = parent.attr('id').replace('lbr-', '');
$(this).html(`<a href=/profiles.php?XID=${user_id}>${username}</a>`);
}
});
}
(function() {
'use strict';
// Your code here...
ajax((page) => {
if (page !== 'loader' && page !== 'page') return;
$('ul.overview').ready(addLinks);
});
$('ul.overview').ready(addLinks);
})();