Get Clan Member Idle Time

Displays the idle time for each clan member.

Author
Dan WL
Daily installs
0
Total installs
40
Ratings
0 0 0
Version
2.1.5
Created
2018-04-11
Updated
2021-03-05
License
N/A
Applies to
Makes it possible to view the idle time, boot% and points for clan members.
To use it, go to Your name > Dan's Userscripts > Get Clan Member Idle Time, enter a clan link then choose the desired option or enter GetIdleTime(clanId); in your browser's console to run it.
The name, title, idle time, boot% and points can be sorted.
Don't close/refresh any script-opened clan page while it's being updated.

Advanced usage (console-only)

number-like = a literal number or a string representing a literal number. E.g. '1' is number-like and 1 is also number-like.

When running from the console, don't close/refresh the "host window" or any clan pages that are opened until the script ends.

Current usage

GetIdleTime(clanIds, options)
clanIds is an array of clan ids (number-like) or a number-like clan id
options is an optional Object

Options

{
	extractedClanMember: function(totalClanMembers),
	extractedClanMembers: function(),
	profilePageLoaded: function(playerInfo),
	doneClan: function(clanInfo),
	doneAllClans: function(allClans),
	errorDetected: function(err)
}
extractedClanMember is executed after a player's name, number and title is extracted from UJS. totalClanMembers is the number of players in the clan. New in 2.1.

extractedClanMembers is executed after all player details are extracted from UJS. New in 2.1.

profilePageLoaded is executed after a player's profile page has been requested. playerInfo is a read-only object containing the following keys:
name: string,
title: string,
lastSeen: string,
boot: number (boot%),
points: int (points in last 30 days),
clan: int,
id: int
pre 2.1- profilePageHTMLString is the string passed to this option.

doneClan is executed when the idle time of all clan members in a clan has been requested and sorted. clanInfo is a read-only object containing a .members object of playerInfo, .id the clan id and .lastUpdate UTC time string. pre 2.1- clanPage is the current clan's Window and is passed to this option.

doneAllClans is executed when the idle time for each clan member in the array of clanIds has been requested and sorted. allClans is an Array of all the clan page Windows that is passed to this option.

errorDetected is executed whenever an error is detected, such as a clan not existing. err is an instance of Error. New in 2.1.

Pre 2.0 usage

GetIdleTime(null, clanIds, options)
null is the click event if the GetIdleTime button is clicked
clanIds is an array of clan ids (number-like) or a number-like clan id
options is an optional Object

Options

{
	profilePageLoaded: function(profilePage),
	doneClan: function(clanPage),
	doneAllClans: function(allClanPages)
}
profilePageLoaded is executed when a player's profile page has loaded. Idle time is calculated by loading a player's profile has a hidden iframe element. profilePage is the iframe window passed to this option.
doneClan is executed when the idle time of all clan members in a clan has been requested and sorted. clanPage is the current clan's Window and is passed to this option.
doneAllClans is executed when the idle time for each clan member in the array of clanIds has been requested and sorted. allClanPages is an Array of all the clan page Windows that is passed to this option.

Examples

To get idle time for a clan:
GetIdleTime(19);
To get idle time for multiple clans:
GetIdleTime([19, 160]);
To gets idle time for two clans: REGL and Warzone Staff. Gets and outputs each clans total points.
(function(){
	const clanIDs = [1, 160];// separate using comma then number for more than one id
	let data = {};
	data.clanPoints = 0;
	let clansPoints = [];

	GetIdleTime(clanIDs, {
		profilePageLoaded: function(profilePageHTMLString)
		{
			let points = profilePageHTMLString.match(/>Points earned in last 30 days:<\/font>\s*((?:(?:\d+|\,))+)\s*/);

			if (points != null) {
				points = parseInt(points[1].replace(",", ""));
			}

			data.clanPoints += points;
		},
		doneClan: function(clanPage)
		{
			const clanID = clanPage.location.href.match(/https:\/\/www\.warzone\.com\/Clans\/\?ID=(\d+)/i)[1];

			clansPoints[clanID] = data.clanPoints;
			data.clanPoints = 0;
		},
		doneAllClans: function(allClans)
		{
			let results = "All clan points";

			clansPoints.forEach((points, id) => {
				results += "\nClan " + id + " points: " + points;
			});

			const resultPage = open();

			resultPage.document.write(results);
		}
	});
})();