linterna-magica-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[linterna-magica-commit] [118] Changes for tasks #11216.


From: Ivaylo Valkov
Subject: [linterna-magica-commit] [118] Changes for tasks #11216.
Date: Thu, 07 Jul 2011 11:55:55 +0000

Revision: 118
          
http://svn.sv.gnu.org/viewvc/?view=rev&root=linterna-magica&revision=118
Author:   valkov
Date:     2011-07-07 11:55:54 +0000 (Thu, 07 Jul 2011)
Log Message:
-----------
Changes for tasks #11216. Added rule to skip xhr if video_id. The changes are 
in use.

Ticket Links:
------------
    http://savannah.gnu.org/task/?11216

Modified Paths:
--------------
    branches/task-11216/src/lm_extract_dom_objects.js
    branches/task-11216/src/lm_site_myvideode.js
    branches/task-11216/src/lm_sites.js

Modified: branches/task-11216/src/lm_extract_dom_objects.js
===================================================================
--- branches/task-11216/src/lm_extract_dom_objects.js   2011-07-07 10:09:56 UTC 
(rev 117)
+++ branches/task-11216/src/lm_extract_dom_objects.js   2011-07-07 11:55:54 UTC 
(rev 118)
@@ -116,18 +116,21 @@
                continue;
            }
 
-           if (/myvideo\.de/i.test(window.location.hostname) &&
-               object_data.video_id)
+           if (object_data.video_id)
            {
-               // See the comments for this function
-               object_data.link = this.create_myvideode_link();
+               var self = this;
+               var val = this.call_site_function_at_position.apply(self,[
+                   "skip_xhr_if_video_id",
+                   window.location.hostname, object_data]);
 
-               // Now that we have a link remove the video_id
-               // so it is not processed
-               if (object_data.link)
+               if (!val)
                {
-                   object_data.video_id = null;
+                   return null;
                }
+               else if(typeof(val) != "boolean")
+               {
+                   object_data = val;
+               }
            }
 
            var parent = object.parentNode.localName.toLowerCase();

Modified: branches/task-11216/src/lm_site_myvideode.js
===================================================================
--- branches/task-11216/src/lm_site_myvideode.js        2011-07-07 10:09:56 UTC 
(rev 117)
+++ branches/task-11216/src/lm_site_myvideode.js        2011-07-07 11:55:54 UTC 
(rev 118)
@@ -74,3 +74,21 @@
 
 // Function reference
 LinternaMagica.prototype.sites["myvideo.de"].flash_plugin_installed = 
"theonion.com";
+
+LinternaMagica.prototype.sites["myvideo.de"].skip_xhr_if_video_id =
+function(object_data)
+{
+    // See the comments for this function. There is no way to access
+    // the video URL via XHR, but there is a pattern to create the
+    // video link
+    object_data.link = this.create_myvideode_link();
+
+    // Now that we have a link remove the video_id
+    // so it is not processed
+    if (object_data.link)
+    {
+       object_data.video_id = null;
+    }
+
+    return object_data ;
+}

Modified: branches/task-11216/src/lm_sites.js
===================================================================
--- branches/task-11216/src/lm_sites.js 2011-07-07 10:09:56 UTC (rev 117)
+++ branches/task-11216/src/lm_sites.js 2011-07-07 11:55:54 UTC (rev 118)
@@ -98,7 +98,15 @@
     return true;
 }
 
-// LinternaMagica.prototype.sites.__skip_xhr_if_video_id
+// Take an action if video_id is extracted, but link extraction could
+// not happen with XHR. See lm_site_myvideode.js:skip_xhr_if_id. The
+// true return value for this default function does not stop XHR. See
+// comments after LinternaMagica.prototype.sites.
+LinternaMagica.prototype.sites.__skip_xhr_if_video_id = function(object_data)
+{
+    return true;
+}
+
 // LinternaMagica.prototype.sites.__wait_before_xhr
 // LinternaMagica.prototype.sites.__extract_scripts_extract_when // Condition 
? DM /ted? 
 // LinternaMagica.prototype.sites.__extract_scripts_once // YT ?




reply via email to

[Prev in Thread] Current Thread [Next in Thread]