Shoutbox

[help] msn chat windows - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Thread: [help] msn chat windows (/showthread.php?tid=69300)

[help] msn chat windows by LifelesS on 12-09-2006 at 04:52 PM

Hi everybody, new around and making my first (useful) script;)

The script I'm making is to easily watch YouTube Videos on MSN, when you send or received a Embed Video link it pops up a window asking if you want to see it, if you say yes, it opens a IE window without anything and with the correct size to view the video.
I'm almost finishing the script but I got a problem when I don't know how to solve it, here's the thing:

The YouTube embed link is this:

code:
<object width="425" height="350"><param name="movie" value="http://www.youtube.com/v/aSdEfRgDFxA"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/aSdEfRgDFxA" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350"></embed></object>

When you send or receive it it will only show "YouTube Embed Link" and it will promp if you want to see it or not. When you say yes, it calls a function called InternetExplorer that opens the IE, but I still need the "IE.navigate()" code. I want to get it from the embed link. But I don't know how. It's a little dificuld to explain...
How can I get the link (in this example is "http://www.youtube.com/v/aSdEfRgDFxA") from the message you send/receive?

The code I have about it is this:

code:
function OnEvent_ChatWndReceiveMessage(ChatWnd, Origin, Message, MessageKind)
{
    var tubeoption = TubeOption.RegRead(TubeOptionPath);
    Debug.Trace(tubeoption);
   
    if(MessageKind == 1)
    {
        Debug.Trace("Text Message received/sent");   
        if(tubeoption == 1)
        {
            Message = Message.replace(/<object width=\"425\" height=\"350\"><param name=\"movie\" value=\"http:\/\/www\.youtube\.com\/v\/[A-Za-z0-9-_][A-Za-z0-9-_][A-Za-z0-9-_][A-Za-z0-9-_][A-Za-z0-9-_][A-Za-z0-9-_][A-Za-z0-9-_][A-Za-z0-9-_][A-Za-z0-9-_][A-Za-z0-9-_][A-Za-z0-9-_]\"><\/param><param name=\"wmode\" value=\"transparent\"><\/param><embed src=\"http:\/\/www\.youtube\.com\/v\/[A-Za-z0-9-_][A-Za-z0-9-_][A-Za-z0-9-_][A-Za-z0-9-_][A-Za-z0-9-_][A-Za-z0-9-_][A-Za-z0-9-_][A-Za-z0-9-_][A-Za-z0-9-_][A-Za-z0-9-_][A-Za-z0-9-_]\" type=\"application\/x-shockwave-flash\" wmode=\"transparent\" width=\"425\" height=\"350\"><\/embed><\/object>/g, "YouTube Embed Video Link");
            if(Message == "YouTube Embed Video Link")
            {
                Debug.Trace("YouTube Embed Video Link");
                MsgPlus.CreateWnd("youtubewindow.xml", "youtubequestion");
            }
                                                           
        }
    }
    return Message;
}

function InternetExplorer(video)
{
    IE.width = "450";
    IE.height = "350";
    IE.statusbar = false;
    IE.toolbar = false;
    IE.menubar = false;
    IE.addressbar = false;
    IE.visible = true;
    IE.navigate(video);
}
function OnyoutubequestionEvent_CtrlClicked(PlusWnd, ControlId)
{                   
    if(ControlId == "BtnYes")
    {
        InternetExplorer(video);       
        PlusWnd.Close(1);
    }
                   
    if(ControlId == "BtnNo")
    {
        PlusWnd.Close(1);
    }
}


Best Regards,
Joćo Godinho

P.S.: I don't know if there's an answer to my question already, I don't how to search it, if there is, my apologies.
RE: [help] msn chat windows by Matti on 12-09-2006 at 06:27 PM

That regular expression is just too complicated! You don't have to repeat a character set time and time again, just use accolades!

Anyway, this code will save the captured video in a global variable and uses a much cleaner regular expression. Try it! ;)

code:
var video = "";

function OnEvent_ChatWndReceiveMessage(ChatWnd, Origin, Message, MessageKind) {
   var tubeoption = TubeOption.RegRead(TubeOptionPath);
   Debug.Trace(tubeoption);
   
   if(MessageKind == 1 && tubeoption == 1) {
      var reYouTube = /<object width=\"425\" height=\"350\"><param name=\"movie\" value=\"http:\/\/www\.youtube\.com\/v\/(.{11})\"><\/param><param name=\"wmode\" value=\"transparent\"><\/param><embed src=\"http:\/\/www\.youtube\.com\/v\/(.{11})\" type=\"application\/x-shockwave-flash\" wmode=\"transparent\" width=\"425\" height=\"350\"><\/embed><\/object>/g;
      if(reTouTube.test(Message) {
            video = RegExp.$1;
            Message = "<YouTube Embed Video Link: "+video+">";
            Debug.Trace("YouTube Embed Video Link captured: "+video);
            MsgPlus.CreateWnd("youtubewindow.xml", "youtubequestion");
         }
      }
   }
   return Message;
}

function InternetExplorer() {
   IE.width = "450";
   IE.height = "350";
   IE.statusbar = false;
   IE.toolbar = false;
   IE.menubar = false;
   IE.addressbar = false;
   IE.visible = true;
   IE.navigate(video);
}

function OnyoutubequestionEvent_CtrlClicked(PlusWnd, ControlId) {               
   if(ControlId == "BtnYes") {
      InternetExplorer();     
      PlusWnd.Close(1);
   } else if(ControlId == "BtnNo") {
      PlusWnd.Close(1);
   }
}

RE: [help] msn chat windows by Felu on 12-09-2006 at 06:29 PM

quote:
Originally posted by LifelesS
MsgPlus.CreateWnd("youtubewindow.xml", "youtubequestion");
You need to use something like
code:
PlusWnd =                 MsgPlus.CreateWnd("youtubewindow.xml", "youtubequestion");

RE: [help] msn chat windows by Plik on 12-09-2006 at 06:38 PM

quote:
Originally posted by -!Felu!-
quote:
Originally posted by LifelesS
MsgPlus.CreateWnd("youtubewindow.xml", "youtubequestion");
You need to use something like
code:
PlusWnd =                 MsgPlus.CreateWnd("youtubewindow.xml", "youtubequestion");

Only if you need to use the window in the current context, which he doesn't............
RE: [help] msn chat windows by LifelesS on 12-09-2006 at 08:25 PM

Many thanks on the quick replys guys!

Mattike, thanks for the help on getting that var smaller... lol
I try it, it had some bad } and a T instead of a Y;) but I got it working and it works 100% :D Many thanks. I'll have it release in no time I hope. Then I'll make some minor adjustements on it.