View Single Post
Author Message
MoggieX
Veteran Member
Join Date: Aug 2007
Location: n00bville
Old 07-20-2009 , 21:36   [iMacros Script] Ban a users steam friends for good measure
Reply With Quote #1

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 (0NumberOfFriends++ )
{
    
// 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(035) == "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(029) == "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 strlen(CommunityID);
    var 
CommunityID.substr(10);
    var 
CommunityID.substr(11);
    var 
AuthID;
    if (
2)
    {
        
AuthID 1;
    }
    else
    {
        
AuthID 0;
    }    
    var 
UserID = (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(filenamedata) {
   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.initWithPathfilename );
   if ( 
file.exists() == false ) {
      
//alert( "Creating file... " );
      
file.createComponents.interfaces.nsIFile.NORMAL_FILE_TYPE420 );
   }
   var 
outputStream Components.classes["@mozilla.org/network/file-output-stream;1"]
      .
createInstanceComponents.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.initfilePR_RDWR PR_CREATE_FILE PR_APPEND420);
   var 
result outputStream.writedatadata.length );
   
outputStream.close();

Attached Files
File Type: zip SteamFriendsToBan.zip (2.6 KB, 159 views)
__________________

Last edited by MoggieX; 07-22-2009 at 07:06.
MoggieX is offline
Send a message via Skype™ to MoggieX