What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » [help] msn chat windows

[help] msn chat windows
Author: Message:
LifelesS
Full Member
***


Posts: 115
Reputation: 4
31 / Male / Flag
Joined: Dec 2006
O.P. Huh?  [help] msn chat windows
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.

This post was edited on 12-09-2006 at 04:58 PM by LifelesS.
12-09-2006 04:52 PM
Profile E-Mail PM Find Quote Report
Matti
Elite Member
*****

Avatar
Script Developer and Helper

Posts: 1646
Reputation: 39
31 / Male / Flag
Joined: Apr 2004
RE: [help] msn chat windows
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);
   }
}

This post was edited on 12-09-2006 at 06:29 PM by Matti.
Plus! Script Developer | Plus! Beta Tester | Creator of Countdown Live | Co-developer of Screenshot Sender 5

Found my post useful? Rate me!
12-09-2006 06:27 PM
Profile E-Mail PM Web Find Quote Report
Felu
Veteran Member
*****


Posts: 2223
Reputation: 72
29 / Male / Flag
Joined: Apr 2006
Status: Away
RE: [help] msn chat windows
quote:
Originally posted by LifelesS
MsgPlus.CreateWnd("youtubewindow.xml", "youtubequestion");
You need to use something like
code:
PlusWnd =                 MsgPlus.CreateWnd("youtubewindow.xml", "youtubequestion");
12-09-2006 06:29 PM
Profile E-Mail PM Web Find Quote Report
Plik
Veteran Member
*****

Avatar

Posts: 1489
Reputation: 46
34 / Male / –
Joined: Jun 2004
RE: [help] msn chat windows
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............
12-09-2006 06:38 PM
Profile PM Find Quote Report
LifelesS
Full Member
***


Posts: 115
Reputation: 4
31 / Male / Flag
Joined: Dec 2006
O.P. RE: [help] msn chat windows
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.
Best Regards,
Joćo Godinho
12-09-2006 08:25 PM
Profile E-Mail PM Find Quote Report
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On