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

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

[linterna-magica-commit] [47] Backport the fix for bugs #33120 to branch


From: Ivaylo Valkov
Subject: [linterna-magica-commit] [47] Backport the fix for bugs #33120 to branch 0.0.9.
Date: Tue, 26 Apr 2011 10:13:33 +0000

Revision: 47
          
http://svn.sv.gnu.org/viewvc/?view=rev&root=linterna-magica&revision=47
Author:   valkov
Date:     2011-04-26 10:13:33 +0000 (Tue, 26 Apr 2011)
Log Message:
-----------
Backport the fix for bugs #33120 to branch 0.0.9. Ready for 0.0.9-4 release.

Ticket Links:
------------
    http://savannah.gnu.org/bugs/?33120

Modified Paths:
--------------
    branches/0.0.9/Makefile
    branches/0.0.9/src/lm_constructors.js
    branches/0.0.9/src/lm_detect_flash.js
    branches/0.0.9/src/lm_log.js
    branches/0.0.9/src/lm_player_button_functions.js

Added Paths:
-----------
    branches/0.0.9/src/lm_inject_script_in_page.js

Modified: branches/0.0.9/Makefile
===================================================================
--- branches/0.0.9/Makefile     2011-04-26 09:29:57 UTC (rev 46)
+++ branches/0.0.9/Makefile     2011-04-26 10:13:33 UTC (rev 47)
@@ -36,7 +36,7 @@
 CHMOD=/bin/chmod
 
 PACKAGE= linternamagica
-VERSION = 0.0.9-3
+VERSION = 0.0.9-4
 
 topdir=.
 srcdir=$(topdir)/src
@@ -52,9 +52,9 @@
 
 USRSCRIPTHDR=$(srcdir)/lm_userscript_header.txt
 
-FIRSTJSFILES="$(srcdir)/lm_init_options.js                     \
-$(srcdir)/lm_localisation.js $(srcdir)/lm_constructors.js      \
-$(srcdir)/lm_config_options.js"
+FIRSTJSFILES="$(srcdir)/lm_inject_script_in_page.js            \
+$(srcdir)/lm_init_options.js $(srcdir)/lm_localisation.js      \
+$(srcdir)/lm_constructors.js $(srcdir)/lm_config_options.js"
 
 LASTJSFILES="$(srcdir)/lm_run.js"
 

Modified: branches/0.0.9/src/lm_constructors.js
===================================================================
--- branches/0.0.9/src/lm_constructors.js       2011-04-26 09:29:57 UTC (rev 46)
+++ branches/0.0.9/src/lm_constructors.js       2011-04-26 10:13:33 UTC (rev 47)
@@ -66,20 +66,8 @@
     // sites in Epiphany (no GM_ API and xmlHttpReqeust is restricted to
     // the same origin).
 
-    var w = null;
-
-    // Firefox adn forks in Greasemonkey
-    try
+    if (window.top != window.self)
     {
-       w = unsafeWindow;
-    }
-    catch(e)
-    {
-       w = window;
-    }
-
-    if (w.top != w.self)
-    {
        this.log("LinternaMagica.constructor:\n"+
                 "Skipping (i)frame with address: "+
                 window.location,1);
@@ -190,7 +178,7 @@
 
 // Release date string in POISIX time format (date +"%s")
 // FIXME: Add real string
-LinternaMagica.prototype.release_date = "1301130751";
+LinternaMagica.prototype.release_date = "1303812612";
 
 // The URL with information about the latest version. Must
 // return JSONP data:

Modified: branches/0.0.9/src/lm_detect_flash.js
===================================================================
--- branches/0.0.9/src/lm_detect_flash.js       2011-04-26 09:29:57 UTC (rev 46)
+++ branches/0.0.9/src/lm_detect_flash.js       2011-04-26 10:13:33 UTC (rev 47)
@@ -32,19 +32,8 @@
 LinternaMagica.prototype.check_flash_plugin = function()
 {
     var is_installed = false;
+    var nav = window.navigator;
 
-    try
-    {
-       // Greasemonkey with Firefox
-       var nav =unsafeWindow.navigator;
-    }
-    catch(e)
-    {
-       // Epiphany && Midori
-       var nav = window.navigator;
-    }
-
-
     if (nav && nav.mimeTypes &&
        nav.mimeTypes.length > 0 &&
        nav.plugins &&

Copied: branches/0.0.9/src/lm_inject_script_in_page.js (from rev 46, 
trunk/src/lm_inject_script_in_page.js)
===================================================================
--- branches/0.0.9/src/lm_inject_script_in_page.js                              
(rev 0)
+++ branches/0.0.9/src/lm_inject_script_in_page.js      2011-04-26 10:13:33 UTC 
(rev 47)
@@ -0,0 +1,58 @@
+//  @licstart The following is the entire license notice for the
+//  JavaScript code in this page (or file).
+//
+//  This file is part of Linterna Mágica
+//
+//  Copyright (C) 2011  Ivaylo Valkov <address@hidden>
+//
+//  The JavaScript code in this page (or file) is free software: you
+//  can redistribute it and/or modify it under the terms of the GNU
+//  General Public License (GNU GPL) as published by the Free Software
+//  Foundation, either version 3 of the License, or (at your option)
+//  any later version.  The code is distributed WITHOUT ANY WARRANTY
+//  without even the implied warranty of MERCHANTABILITY or FITNESS
+//  FOR A PARTICULAR PURPOSE.  See the GNU GPL for more details.
+//
+//  As additional permission under GNU GPL version 3 section 7, you
+//  may distribute non-source (e.g., minimized or compacted) forms of
+//  that code without the copy of the GNU GPL normally required by
+//  section 4, provided you include this license notice and a URL
+//  through which recipients can access the Corresponding Source.
+//
+//  @licend The above is the entire license notice for the JavaScript
+//  code in this page (or file).
+//
+// @source http://e-valkov.org/linterna-magica
+
+// END OF LICENSE HEADER
+
+// This file must be concatenated firs in the Makefile. It injects the
+// entire userscript in the page if Greasemonkey is detected. in
+// Epiphany and Midori it is already running in the page scope. 
+// See https://savannah.nongnu.org/bugs/?33120
+
+// We are running in Greasemonkey and the userscript is not inject in
+// the page yet.
+if (typeof(unsafeWindow) == "object")
+{
+    (function inject_in_page() 
+     {
+        var userscript_data = inject_in_page.caller.toString();
+        var script = document.createElement("script");
+        script.setAttribute("type", "text/javascript");
+        script.setAttribute("src", 
+                            "data:text/javascript;charset=UTF-8,"+
+                            "("+userscript_data+")();");
+
+        var inject_data = function()
+        {
+            var head = document.getElementsByTagName("head")[0];
+            head.appendChild(script);
+            head.removeChild(script);
+        }
+
+        setTimeout(inject_data, 0);
+     })();
+
+    return;
+}

Modified: branches/0.0.9/src/lm_log.js
===================================================================
--- branches/0.0.9/src/lm_log.js        2011-04-26 09:29:57 UTC (rev 46)
+++ branches/0.0.9/src/lm_log.js        2011-04-26 10:13:33 UTC (rev 47)
@@ -87,24 +87,7 @@
        }
        catch(e)
        {
-           try
-           {
-               // Greasemonkey 0.8.2 does not print to fireBug
-               // console with console.log
-               try
-               {
-                   unsafeWindow.console.log(log_string);
-               }
-               catch(e)
-               {
-                   // Epiphany
-                   console.log(log_string);
-               }       
-           }
-           catch(e)
-           {
-               // The only option left is alert(), but is useless;
-           }
+           console.log(log_string);
        }
     }
 }

Modified: branches/0.0.9/src/lm_player_button_functions.js
===================================================================
--- branches/0.0.9/src/lm_player_button_functions.js    2011-04-26 09:29:57 UTC 
(rev 46)
+++ branches/0.0.9/src/lm_player_button_functions.js    2011-04-26 10:13:33 UTC 
(rev 47)
@@ -31,25 +31,13 @@
 // Find the current video object in the DOM
 LinternaMagica.prototype.get_video_object = function(id)
 {
-    var video_object = null;
-    // greasemonkey in Iceweasel
-    try
-    {
-       video_object = unsafeWindow.document.
-           getElementById("linterna-magica-video-object-"+id);
-    }
-    // Epiphany
-    catch(e)
-    {
-       video_object = window.document.
-           getElementById("linterna-magica-video-object-"+id);
-    }
+    var video_object  = window.document.
+       getElementById("linterna-magica-video-object-"+id);
 
     return video_object;
 }
 
 
-
 // Set player_name attribute to video objects.
 // This is used to know wchich API to use
 // navigator.plugins[x].name:
@@ -64,17 +52,8 @@
 {
     var name = null;
     var video_object = this.get_video_object(id);
-    var mimeTypes = null;
+    var mimeTypes = navigator.mimeTypes;
 
-    try
-    {
-       mimeTypes = unsafeWindow.navigator.mimeTypes;
-    }
-    catch(e)
-    {
-       mimeTypes = navigator.mimeTypes;
-    }
-
     var mime = mimeTypes[video_object.getAttribute("type")];
 
     if (mime && mime.enabledPlugin && mime.enabledPlugin.name)




reply via email to

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