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

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

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


From: Ivaylo Valkov
Subject: [linterna-magica-commit] [130] Changes for tasks #11216.
Date: Thu, 14 Jul 2011 10:53:00 +0000

Revision: 130
          
http://svn.sv.gnu.org/viewvc/?view=rev&root=linterna-magica&revision=130
Author:   valkov
Date:     2011-07-14 10:52:59 +0000 (Thu, 14 Jul 2011)
Log Message:
-----------
Changes for tasks #11216. Added rule to stop object search and extraction after 
one object is found. Sites that need the change use it.

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

Modified Paths:
--------------
    branches/task-11216/src/lm_extract_js_scripts.js
    branches/task-11216/src/lm_site_youtube.js
    branches/task-11216/src/lm_sites.js

Modified: branches/task-11216/src/lm_extract_js_scripts.js
===================================================================
--- branches/task-11216/src/lm_extract_js_scripts.js    2011-07-13 09:26:07 UTC 
(rev 129)
+++ branches/task-11216/src/lm_extract_js_scripts.js    2011-07-14 10:52:59 UTC 
(rev 130)
@@ -121,17 +121,6 @@
                     object_data.video_id,1);
 
            this.request_video_link(object_data);
-
-           if (/youtube\.com/i.test(window.location.hostname) ||
-               (/youtube-nocookie\.com/i.test(window.location.hostname)))
-           {
-               // We assume there is only one object per page in 
-               // YouTube found trough scripts.
-               // Stop processing, so it will not bloat.
-               this.log("LinternaMagica.constructor:\n"+
-                        "Found one object in YouTube. Stopping script 
processing",1);
-               break;
-           }
        }
 
        if (object_data && object_data.link)
@@ -161,5 +150,18 @@
                    }, 500);
            }
        }
+
+       if (object_data && (object_data.video_id || object_data.link))
+       {
+           var self = this;
+           var val = this.call_site_function_at_position.apply(self,[
+               "stop_if_one_extracted_object_from_script",
+               window.location.hostname]);
+
+           if (!val)
+           {
+               break;
+           }
+       }
     }
 }

Modified: branches/task-11216/src/lm_site_youtube.js
===================================================================
--- branches/task-11216/src/lm_site_youtube.js  2011-07-13 09:26:07 UTC (rev 
129)
+++ branches/task-11216/src/lm_site_youtube.js  2011-07-14 10:52:59 UTC (rev 
130)
@@ -329,3 +329,13 @@
 
     return object_data;
 }
+
+LinternaMagica.prototype.sites["youtube.com"].
+    stop_if_one_extracted_object_from_script =
+function()
+{
+    this.log("LinternaMagica.sites.stop_if_"+
+            "one_extracted_object_from_script:\n"+
+            "Found one object in YouTube. Stopping script processing",3);
+    return false;
+}

Modified: branches/task-11216/src/lm_sites.js
===================================================================
--- branches/task-11216/src/lm_sites.js 2011-07-13 09:26:07 UTC (rev 129)
+++ branches/task-11216/src/lm_sites.js 2011-07-14 10:52:59 UTC (rev 130)
@@ -149,8 +149,15 @@
     return true;
 }
 
+// If one video object is found, stop all further searches in scripts.
+LinternaMagica.prototype.sites.__stop_if_one_extracted_object_from_script =
+function()
+{
+    return true;
+}
+
 // LinternaMagica.prototype.sites.__extract_scripts_extract_when // Condition 
? DM /ted? 
-// LinternaMagica.prototype.sites.__extract_scripts_once // YT ?
+
 // LinternaMagica.prototype.sites.__extract_scripts_wait_insert // FB
 // LinternaMagica.prototype.sites.__wait_before_inserting_object_from-script 
// FB
 // LinternaMagica.prototype.sites.__extract_swfobject_regex




reply via email to

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