[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[linterna-magica-commit] [46] Closes bugs #33120.
From: |
Ivaylo Valkov |
Subject: |
[linterna-magica-commit] [46] Closes bugs #33120. |
Date: |
Tue, 26 Apr 2011 09:29:58 +0000 |
Revision: 46
http://svn.sv.gnu.org/viewvc/?view=rev&root=linterna-magica&revision=46
Author: valkov
Date: 2011-04-26 09:29:57 +0000 (Tue, 26 Apr 2011)
Log Message:
-----------
Closes bugs #33120. All references to unsafeWindow removed. The script runs in
the page.
Ticket Links:
------------
http://savannah.gnu.org/bugs/?33120
Modified Paths:
--------------
trunk/Makefile
trunk/src/lm_constructors.js
trunk/src/lm_detect_flash.js
trunk/src/lm_log.js
trunk/src/lm_player_button_functions.js
trunk/src/lm_run.js
Added Paths:
-----------
trunk/src/lm_inject_script_in_page.js
Modified: trunk/Makefile
===================================================================
--- trunk/Makefile 2011-04-09 17:05:28 UTC (rev 45)
+++ trunk/Makefile 2011-04-26 09:29:57 UTC (rev 46)
@@ -52,8 +52,9 @@
USRSCRIPTHDR=$(srcdir)/lm_userscript_header.txt
-FIRSTJSFILES="$(srcdir)/lm_init_options.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_constructors.js \
+$(srcdir)/lm_config_options.js"
LASTJSFILES="$(srcdir)/lm_run.js"
Modified: trunk/src/lm_constructors.js
===================================================================
--- trunk/src/lm_constructors.js 2011-04-09 17:05:28 UTC (rev 45)
+++ trunk/src/lm_constructors.js 2011-04-26 09:29:57 UTC (rev 46)
@@ -35,21 +35,9 @@
// video. This way it might be possible to play videos from remote
// sites in Epiphany (no GM_ API and xmlHttpReqeust is restricted to
// the same origin).
-
- var w = null;
-
- // GNU IceCat and other version of Firefox with 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);
Modified: trunk/src/lm_detect_flash.js
===================================================================
--- trunk/src/lm_detect_flash.js 2011-04-09 17:05:28 UTC (rev 45)
+++ trunk/src/lm_detect_flash.js 2011-04-26 09:29:57 UTC (rev 46)
@@ -33,18 +33,10 @@
{
var is_installed = false;
- try
- {
- // Greasemonkey with Firefox
- var nav =unsafeWindow.navigator;
- }
- catch(e)
- {
- // Epiphany && Midori
- var nav = window.navigator;
- }
+ // OK even in Greasemonkey. Since 0.0.9-4 Linterna Magica is
+ // injected in the page.
+ var nav = window.navigator;
-
if (nav && nav.mimeTypes &&
nav.mimeTypes.length > 0 &&
nav.plugins &&
Added: trunk/src/lm_inject_script_in_page.js
===================================================================
--- trunk/src/lm_inject_script_in_page.js (rev 0)
+++ trunk/src/lm_inject_script_in_page.js 2011-04-26 09:29:57 UTC (rev 46)
@@ -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: trunk/src/lm_log.js
===================================================================
--- trunk/src/lm_log.js 2011-04-09 17:05:28 UTC (rev 45)
+++ trunk/src/lm_log.js 2011-04-26 09:29:57 UTC (rev 46)
@@ -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: trunk/src/lm_player_button_functions.js
===================================================================
--- trunk/src/lm_player_button_functions.js 2011-04-09 17:05:28 UTC (rev 45)
+++ trunk/src/lm_player_button_functions.js 2011-04-26 09:29:57 UTC (rev 46)
@@ -32,24 +32,14 @@
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);
- }
+ 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 +54,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)
Modified: trunk/src/lm_run.js
===================================================================
--- trunk/src/lm_run.js 2011-04-09 17:05:28 UTC (rev 45)
+++ trunk/src/lm_run.js 2011-04-26 09:29:57 UTC (rev 46)
@@ -42,21 +42,10 @@
var ready_to_init = 0;
- var data_window = null;
-
- try
- {
- data_window = unsafeWindow;
- }
- catch(e)
- {
- data_window = window;
- }
-
// 1.5 second with 250 ms interval.
if (window.linterna_magica_init_counter >= 6 ||
- data_window.linterna_magica_user_config != undefined ||
- data_window.LinternaMagica_L10N != undefined)
+ window.linterna_magica_user_config != undefined ||
+ window.LinternaMagica_L10N != undefined)
{
clearInterval(window.linterna_magica_init_timeout);
ready_to_init = 1;
@@ -69,11 +58,11 @@
for (var o in linterna_magica_options)
{
// We could be running without custom config
- if (data_window.linterna_magica_user_config != undefined &&
+ if (window.linterna_magica_user_config != undefined &&
// Zero migth be an option
- data_window.linterna_magica_user_config[o] != undefined)
+ window.linterna_magica_user_config[o] != undefined)
{
- config[o] = data_window.linterna_magica_user_config[o];
+ config[o] = window.linterna_magica_user_config[o];
}
else
{
@@ -81,15 +70,15 @@
}
}
- delete data_window.linterna_magica_user_config;
+ delete window.linterna_magica_user_config;
- for (var loc in data_window.LinternaMagica_L10N)
+ for (var loc in window.LinternaMagica_L10N)
{
LinternaMagica.prototype.languages[loc] =
- data_window.LinternaMagica_L10N[loc];
+ window.LinternaMagica_L10N[loc];
// Direction value must be lowercase
- var dir = data_window.LinternaMagica_L10N[loc]["__direction"];
+ var dir = window.LinternaMagica_L10N[loc]["__direction"];
// Wrong value
if (dir != "rtl" &&
@@ -102,7 +91,7 @@
dir.toLowerCase();
}
- delete data_window.LinternaMagica_L10N;
+ delete window.LinternaMagica_L10N;
// Init
var larerna_magica = new LinternaMagica(config);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [linterna-magica-commit] [46] Closes bugs #33120.,
Ivaylo Valkov <=