[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[linterna-magica-commit] [111] Changes for tasks #11216.
From: |
Ivaylo Valkov |
Subject: |
[linterna-magica-commit] [111] Changes for tasks #11216. |
Date: |
Tue, 05 Jul 2011 14:51:35 +0000 |
Revision: 111
http://svn.sv.gnu.org/viewvc/?view=rev&root=linterna-magica&revision=111
Author: valkov
Date: 2011-07-05 14:51:34 +0000 (Tue, 05 Jul 2011)
Log Message:
-----------
Changes for tasks #11216. Added rule for processing cookies. Sites requiring
this change use the new framework.
Ticket Links:
------------
http://savannah.gnu.org/task/?11216
Modified Paths:
--------------
branches/task-11216/src/lm_cookies.js
branches/task-11216/src/lm_site_dailymotion.js
branches/task-11216/src/lm_site_youtube.js
branches/task-11216/src/lm_sites.js
Modified: branches/task-11216/src/lm_cookies.js
===================================================================
--- branches/task-11216/src/lm_cookies.js 2011-07-05 12:23:13 UTC (rev
110)
+++ branches/task-11216/src/lm_cookies.js 2011-07-05 14:51:34 UTC (rev
111)
@@ -49,26 +49,56 @@
var past_date = new Date(1983, 9, 27);
var domain = window.location.hostname;
- if (/youtube\.com/i.test(window.location.hostname))
+ var self = this;
+ var val = this.call_site_function_at_position.apply(self,[
+ "set_cookies_domain",
+ window.location.hostname]);
+
+ if (!val)
{
- domain = ".youtube.com";
+ return null;
}
+ else if (typeof(val) == "string")
+ {
+ // See YouTube support.
+ domain = val;
+ }
- for (var i=0; i<cookies.length; i++)
+ for (var i=0, l=cookies.length; i<l; i++)
{
- // Host is used in dailymotion. It is not documented anywhere
- document.cookie = cookies[i]+
- (expire ? "; expires="+past_date.toUTCString(): "")+
- "; domain="+domain+"; path=/; host="+domain+"; ";
+ var val = this.call_site_function_at_position.apply(self,[
+ "process_cookies",
+ window.location.hostname]);
- // Dailymotion uses www.dailymotion.com and .dailymotion.com
- if (/dailymotion\.com/i.test(window.location.hostname))
+ try
{
- // Host is used in dailymotion. It is not documented anywhere
+ if (typeof(val) == "string")
+ {
+ document.cookie = cookies[i]+
+ (expire ? "; expires="+
+ past_date.toUTCString(): "")+val;
+ }
+ }
+ catch(e)
+ {
+ this.log("LinternaMagica.store_cookies:\n"+
+ "Exception while setting cookie with"+
+ " site specific string: "+e,1);
+ }
+
+ try
+ {
+ // Host is used in dailymotion. It is not documented
+ // anywhere. It is overkill to export it.
document.cookie = cookies[i]+
(expire ? "; expires="+past_date.toUTCString(): "")+
- "; domain=.dailymotion.com; path=/; host="+domain+"; ";
+ "; domain="+domain+"; path=/; host="+domain+"; ";
}
+ catch(e)
+ {
+ this.log("LinternaMagica.store_cookies:\n"+
+ "Exception while setting cookie: "+e,1);
+ }
}
}
Modified: branches/task-11216/src/lm_site_dailymotion.js
===================================================================
--- branches/task-11216/src/lm_site_dailymotion.js 2011-07-05 12:23:13 UTC
(rev 110)
+++ branches/task-11216/src/lm_site_dailymotion.js 2011-07-05 14:51:34 UTC
(rev 111)
@@ -80,3 +80,13 @@
this.request_video_link({video_id: window.location.pathname});
return true;
}
+
+LinternaMagica.prototype.sites["dailymotion.com"].process_cookies =
+function()
+{
+ // Dailymotion is processed twice. Once with .dailymotion.com. The
+ // second time with www.dailymotion.com. They set cookies very
+ // strange. Also they use host= which is not documented anywhere
+ // (DOM 0,1...).
+ return "; domain=.dailymotion.com; path=/;
host="+window.location.hostname+"; ";
+}
Modified: branches/task-11216/src/lm_site_youtube.js
===================================================================
--- branches/task-11216/src/lm_site_youtube.js 2011-07-05 12:23:13 UTC (rev
110)
+++ branches/task-11216/src/lm_site_youtube.js 2011-07-05 14:51:34 UTC (rev
111)
@@ -302,3 +302,14 @@
return null;
}
+
+LinternaMagica.prototype.sites["youtube.com"] = new Object();
+
+// Reference
+LinternaMagica.prototype.sites["www.youtube.com"] = "youtube.com";
+
+LinternaMagica.prototype.sites["youtube.com"].set_cookies_domain =
+function()
+{
+ return ".youtube.com";
+}
Modified: branches/task-11216/src/lm_sites.js
===================================================================
--- branches/task-11216/src/lm_sites.js 2011-07-05 12:23:13 UTC (rev 110)
+++ branches/task-11216/src/lm_sites.js 2011-07-05 14:51:34 UTC (rev 111)
@@ -61,7 +61,22 @@
return true;
}
-// LinternaMagica.prototype.sites.__process_cookies
+// Set the domain used to process (expire) cookies. Not required for
+// most sites. See lm_site_youtube.js:set_cookies_domain.
+LinternaMagica.prototype.sites.__set_cookies_domain = function()
+{
+ return true;
+}
+
+// Take an action while processing cookies. This is executed for every
+// cookie object. Duplicates normal cookies processing. Not needed
+// form most sites. It should return a string with domain, path and
+// other values. See lm_site_dailymotion.js:prcoess_cookies.
+LinternaMagica.prototype.sites.__process_cookies = function()
+{
+ return true;
+}
+
// LinternaMagica.prototype.sites.__css_style_fix
// LinternaMagica.prototype.sites.__detect_flash_ // Useless?
// LinternaMagica.prototype.sites.__skip_video_id_extract // DM force?
@@ -91,6 +106,15 @@
{
var self = this;
+ var debug_level = 5;
+
+ if (position_name == "process_cookies")
+ {
+ // The process_cookies function is called inside a loop and
+ // prints too much information for debug level 5.
+ debug_level = 7;
+ }
+
if (this.sites[match_site])
{
// Recursion is used to handle references to strings.
@@ -102,7 +126,7 @@
this.log("LinternaMagica.call_site_function_at_position:\n"+
"Calling function "+position_name+
- "for site (both site and function defined)",5);
+ " for site (both site and function defined)",debug_level);
return this.sites[match_site][position_name].apply(self,[data]);
}
@@ -116,7 +140,7 @@
this.log("LinternaMagica.call_site_function_at_position:\n"+
"Calling referenced function "+
position_name+" (site defined,"+
- " function reference): "+match_site+" -> "+ref_to,5);
+ " function reference): "+match_site+" ->
"+ref_to,debug_level);
return this.call_site_function_at_position.apply(self, [
position_name, ref_to, data]);
@@ -129,7 +153,7 @@
this.log("LinternaMagica.call_site_function_at_position:\n"+
"Using another site config (reference) for function "+
- position_name+": "+match_site+" -> "+ref_to,5);
+ position_name+": "+match_site+" -> "+ref_to,debug_level);
return this.call_site_function_at_position.apply(self, [
position_name, ref_to, data]);
@@ -143,7 +167,7 @@
this.log("LinternaMagica.call_site_function_at_position:\n"+
"Using default function "+position_name+
- "(no site specific config)",5);
+ " (no site specific config)",debug_level);
return this.sites["__"+position_name].apply(self, [data]);
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [linterna-magica-commit] [111] Changes for tasks #11216.,
Ivaylo Valkov <=