Ejemplo n.º 1
0
        private void HandlePageChanged()
        {
            _track = null;

            //Reset the track when the page has finished loading, this will be triggered if users launch any links on the page.
            if (JangoBrowser.Window.Frames.Count <= 0) return;

            //Get the frame jango is running in
            var jangoFrame = JangoBrowser.Window.Frames[1].Document;

            if (!_injectedJs && jangoFrame.DocumentElement.GetElementsByTagName("body").Count > 0)
            {
                //We are using an older version of Firefox and the XUL runner so we need to define what the click method is.
                //TODO: consider upgrading to a newer version of XUL runner, or anotehr browser control.
                //It is a shame the built in IE control sucks.
                _injectedJs = true;
                var body = jangoFrame.DocumentElement.GetElementsByTagName("body")[0];
                var injectedFunctions = jangoFrame.CreateElement("script");
                injectedFunctions.TextContent =
                    "HTMLElement.prototype.click = function() { var evt = this.ownerDocument.createEvent('MouseEvents'); evt.initMouseEvent('click', true, true, this.ownerDocument.defaultView, 1, 0, 0, 0, 0, false, false, false, false, 0, null); this.dispatchEvent(evt); } ";
                body.AppendChild(injectedFunctions);

            }

            var currentEle = jangoFrame.GetElementById("current-song");

            if (currentEle != null && currentEle.InnerHtml != null)
            {
                _track = new Track(JangoBrowser.Window.Frames[1].Document);
                _pageNeedsParsing = false;
            }

            // Submit a vote/rate if need be
            if (jangoFrame.GetElementsByName("commit").Count > 0)
            {
                SubmitRate();
            }
        }
Ejemplo n.º 2
0
 private void JangoBrowser_DocumentTitleChanged(object sender, EventArgs e)
 {
     //Usually when the Title changes the song has changed, so check to see if we need to parse songs.
     if (JangoBrowser.Window.Frames.Count > 0 && _track == null)
         _track = new Track(JangoBrowser.Window.Frames[1].Document);
 }