Support Forums

Full Version: Little Msn Script help
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello, This is someone elses script but i want to edit it for my personal use. Anyway here is the code;

Code:
function FilterString( str )
{
    var googleMatches = null;
    
    //While a match is found to the regular expression
    while( (googleMatches = str.match( "Google\\(.*?\\)" )) != null )
    {
        //Get string
        var googleString = googleMatches[0];
        Debug.Trace( googleString )
        
        //Get the search text
        var searchText = googleString.substring(7, googleString.length-1);
        
        //Replace all spaces with +'s
        searchText = searchText.replace(' ', '+');
        
        //Make it into it's final form
        searchText = "http://lmgtfy.com/?q=" + searchText;
        
        //Replace
        str = str.replace( googleString, searchText );
    }
    
    //Return
    return str;
}

function OnEvent_ChatWndSendMessage(ChatWnd, Message)
{
    return FilterString( Message );
}

What i want to change it instead of it replace the text that i send e.g 'Google(test)'

I want it to send 'Google (test)' then the link.
Thanks for help Smile
I don't really understand what you want to do.
Please put the code into [ code ] [/ code ] tags (without whitespace)

The code matches Google\\(.*?\\) and then make that into a link and finally it replaces, str = str.replace( googleString, searchText );
Ok when you put in msn 'Google(Test)'
It will replace the whole text and then send the link instead i want it to send Google(Test) followed by the link on seperate lines?
Before or after the line,
Code:
var googleMatches = null;

Call the function that sends the message, and let it send the "str" variable... example: sendMessage(str)
I don't know since thats not the whole source....