Howdy,
I'm perfectly aware I may get flamed to the ground for posting this. However I've found that idiots attract idiots and if we discover one, we'll not only ban them, but we'll take their steam friends and ban them as well for good measure.
The attached is a iMacros JavaScript file that will scroll through a steam friends page and convert names and community ID's to steam ID's and put them into a text file for external processing.
Requirements:
iMacros -
http://www.iopus.com/download/ (which is Free, tested using FireFox version!)
Instructions
1. Place the SteamFriendsToBan.js in your iMacros folder (normally C:\Documents and Settings\USER\My Documents\iMacros\Macros)
2. Open the attached JS file, alter the following to your own liking and save
- SteamFriendsURL
- NumberOfFriends
3. Run the file, within a few moments a file at C:\\SteamFriendsToBan.txt will be created with a list of steam ID's for external use
TIP: http://wiki.imacros.net/iMacros_for_...ting_Interface
By default each Javascript step is shown during replay. This option is useful for testing and debugging, but it slows down the Javascript execution artificially. To run Javascript at its normal (very fast) speed please uncheck this option.
Code:
PHP Code:
//////////////////////////////////////////////////////////
//
// iMacros ban their friends for good measure script
//
// After the fiel has been run, check the text file at:
// C:\\SteamFriendsToBan.txt
//
//////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////
// Configurable Section
//////////////////////////////////////////////////////////
var SteamFriendsURL = "http://steamcommunity.com/profiles/76561197961403283/friends"
// Example: http://steamcommunity.com/profiles/76561197961403283/friends
var NumberOfFriends = 20
// Number of times to repeat, put 255 if unsure, it will take longer and most likely give errors, but thats the max steam friends a single player can have
//////////////////////////////////////////////////////////
// vars Leave these ones ALONE!
//////////////////////////////////////////////////////////
var i=0; // For cycling
var JSNewLine="\n"; // new Line
var MyMacroCode; // For running the code
var MyMacroCode2; // For running the code2
var LoopCounter = 1; // Used to loop
var DeBug=0; // Added for debugging, set to 0 to turn off
var CheckExtract; // Var to dump extract in
var CommunityID; // var to dump community ID in
var CommunityXML; // To Hold XML
//////////////////////////////////////////////////////////
// Main Function
//////////////////////////////////////////////////////////
for (i = 0; i < NumberOfFriends; i ++ )
{
// Reset vars
MyMacroCode = "";
MyMacroCode2 = "";
CheckExtract = "";
CommunityID = "";
SteamID = "";
CommunityXML = "";
// Build the macro
MyMacroCode = "CODE:"
MyMacroCode = MyMacroCode + "TAB T=1" + JSNewLine
MyMacroCode = MyMacroCode + "SET !VAR1 !EXTRACT" + JSNewLine
MyMacroCode = MyMacroCode + "URL GOTO=" + SteamFriendsURL + JSNewLine
MyMacroCode = MyMacroCode + "TAG POS=" + LoopCounter +" TYPE=A ATTR=CLASS:linkFriend*&&TXT:*&&HREF:http://steamcommunity.com/* EXTRACT=HREF" + JSNewLine
iimPlay(MyMacroCode)
CheckExtract = iimGetLastExtract()
if (DeBug == 1)
{
alert("CheckExtract: " + CheckExtract);
}
if (CheckExtract == "#EANF#")
{
// Now because some use iconHolder_ instead, lets run with the same tag number to make sure we get the bastards
MyMacroCode2 = "CODE:"
MyMacroCode2 = MyMacroCode2 + "TAB T=1" + JSNewLine
MyMacroCode2 = MyMacroCode2 + "SET !VAR1 !EXTRACT" + JSNewLine
MyMacroCode2 = MyMacroCode2 + "URL GOTO=" + SteamFriendsURL + JSNewLine
MyMacroCode2 = MyMacroCode2 + "TAG POS=" + LoopCounter +" TYPE=A ATTR=CLASS:iconHolder_*&&TXT:*&&HREF:http://steamcommunity.com/* EXTRACT=HREF" + JSNewLine
iimPlay(MyMacroCode2)
CheckExtract = iimGetLastExtract()
if (DeBug == 1)
{
alert("CheckExtract: " + CheckExtract);
}
}
// If its Still #EANF# then bail
if (CheckExtract == "#EANF#")
{
alert("EOF");
}
else if (CheckExtract.substr(0, 35) == "http://steamcommunity.com/profiles/")
{
// Normal Profile with Community ID
CommunityID = CheckExtract.replace("http://steamcommunity.com/profiles/", "");
if (DeBug == 1)
{
alert("CommunityID = " + CommunityID );
}
// Make that ID into a Steam ID
SteamID = convertToID(CommunityID);
if (DeBug == 1)
{
alert("The SteamID is: " + SteamID);
}
}
else if (CheckExtract.substr(0, 29) == "http://steamcommunity.com/id/") // http://steamcommunity.com/id/
{
// This is the awkward one, we need to go hunting in XML
// Needs to be profile + ?xml=1
CommunityXML = CheckExtract + "?xml=1";
if (DeBug == 1)
{
alert(CommunityXML);
}
xmlDoc = loadXMLDoc(CommunityXML);
// Get Community ID
CommunityID = xmlDoc.getElementsByTagName("steamID64")[0].childNodes[0].nodeValue;
if (DeBug == 1)
{
alert(CommunityID);
}
// Make that ID into a Steam ID
SteamID = convertToID(CommunityID);
if (DeBug == 1)
{
alert(SteamID);
}
}
if (LoopCounter == 1)
{
// Make a pretty header
writeToFile("C:\\SteamFriendsToBan.txt","ID, CommunityID, SteamID\r\n");
writeToFile("C:\\SteamFriendsToBan.txt","" + LoopCounter + "," + CommunityID + "," + SteamID + "\r\n");
}
else
{
writeToFile("C:\\SteamFriendsToBan.txt","" + LoopCounter + "," + CommunityID + "," + SteamID + "\r\n");
}
// loop back up
LoopCounter = LoopCounter + 1
}
//////////////////////////////////////////////////////////
// Convert to Steam ID from Community ID
//////////////////////////////////////////////////////////
function convertToID(CommunityID)
{
//CommunityID = CommunityID.replace("http://steamcommunity.com/profiles/", ""); //remove http://steamcommunity.com/profiles/
var x = strlen(CommunityID);
var z = CommunityID.substr(x - 10);
var y = CommunityID.substr(x - 1, 1);
var AuthID;
if (y % 2)
{
AuthID = 1;
}
else
{
AuthID = 0;
}
var UserID = (z - 7960265728 - AuthID) / 2;
SteamID = "STEAM_0:" + AuthID + ":" + UserID;
return SteamID;
}
//////////////////////////////////////////////////////////
// strlen function as JS does not have it
//////////////////////////////////////////////////////////
function strlen(strVar)
{
return(strVar.length)
}
//////////////////////////////////////////////////////////
// XML Function
//////////////////////////////////////////////////////////
function loadXMLDoc(dname)
{
var xmlDoc;
if (window.XMLHttpRequest)
{
xmlDoc=new window.XMLHttpRequest();
xmlDoc.open("GET",dname,false);
xmlDoc.send("");
return xmlDoc.responseXML;
}
// IE 5 and IE 6
else if (ActiveXObject("Microsoft.XMLDOM"))
{
xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async=false;
xmlDoc.load(dname);
return xmlDoc;
}
alert("Error loading document");
return null;
}
//////////////////////////////////////////////////////////
// File Writing Function
// Code from http://www.captain.at/programming/xul/
// Filename: writeToFile.js
//////////////////////////////////////////////////////////
function writeToFile(filename, data) {
try {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
} catch (e) {
alert("Permission to save file was denied.");
}
var file = Components.classes["@mozilla.org/file/local;1"]
.createInstance(Components.interfaces.nsILocalFile);
file.initWithPath( filename );
if ( file.exists() == false ) {
//alert( "Creating file... " );
file.create( Components.interfaces.nsIFile.NORMAL_FILE_TYPE, 420 );
}
var outputStream = Components.classes["@mozilla.org/network/file-output-stream;1"]
.createInstance( Components.interfaces.nsIFileOutputStream );
// Open flags
var PR_RDONLY = 0x01
var PR_WRONLY = 0x02
var PR_RDWR = 0x04
var PR_CREATE_FILE = 0x08
var PR_APPEND = 0x10
var PR_TRUNCATE= 0x20
var PR_SYNC = 0x40
var PR_EXCL = 0x80
/*
** File modes ....
**
** CAVEAT: 'mode' is currently only applicable on UNIX platforms.
** The 'mode' argument may be ignored by PR_Open on other platforms.
**
** 00400 Read by owner.
** 00200 Write by owner.
** 00100 Execute (search if a directory) by owner.
** 00040 Read by group.
** 00020 Write by group.
** 00010 Execute by group.
** 00004 Read by others.
** 00002 Write by others
** 00001 Execute by others.
**
*/
outputStream.init( file, PR_RDWR | PR_CREATE_FILE | PR_APPEND, 420, 0 );
var result = outputStream.write( data, data.length );
outputStream.close();
}