[Pkg-mozext-commits] [greasemonkey] 08/21: Simplify frame scope content observer into an object literal.

David Prévot taffit at moszumanska.debian.org
Sun Sep 13 21:27:15 UTC 2015


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository greasemonkey.

commit 16be5cbb292eb6d489c05b5d3e421886e4f4f649
Author: Anthony Lieuallen <arantius at gmail.com>
Date:   Wed Jul 15 15:15:12 2015 -0400

    Simplify frame scope content observer into an object literal.
---
 content/framescript.js | 57 ++++++++++++++++++++++----------------------------
 1 file changed, 25 insertions(+), 32 deletions(-)

diff --git a/content/framescript.js b/content/framescript.js
index a65e8ce..f30bc31 100644
--- a/content/framescript.js
+++ b/content/framescript.js
@@ -24,37 +24,31 @@ var gStripUserPassRegexp = new RegExp('(://)([^:/]+)(:[^@/]+)?@');
 
 // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ //
 
-function ContentObserver() {
-}
-
-
-ContentObserver.prototype.QueryInterface = XPCOMUtils.generateQI([
-    Ci.nsIObserver]);
-
-
-ContentObserver.prototype.observe = function(aSubject, aTopic, aData) {
-  if (!GM_util.getEnabled()) return;
-
-  switch (aTopic) {
-    case 'document-element-inserted':
-      if (!GM_util.getEnabled()) return;
-
-      var doc = aSubject;
-      var win = doc && doc.defaultView;
-      if (!doc || !win) return;
-      if (win.top !== content) return;
-
-      var url = doc.documentURI;
-      if (!GM_util.isGreasemonkeyable(url)) return;
-
-      // Listen for whichever kind of load event arrives first.
-      win.addEventListener('DOMContentLoaded', contentLoad, true);
-      win.addEventListener('load', contentLoad, true);
-
-      runScripts('document-start', win);
-      break;
-    default:
-      dump('Content frame observed unknown topic: ' + aTopic + '\n');
+var contentObserver = {
+  observe: function (aSubject, aTopic, aData) {
+    if (!GM_util.getEnabled()) return;
+
+    switch (aTopic) {
+      case 'document-element-inserted':
+        if (!GM_util.getEnabled()) return;
+
+        var doc = aSubject;
+        var win = doc && doc.defaultView;
+        if (!doc || !win) return;
+        if (win.top !== content) return;
+
+        var url = doc.documentURI;
+        if (!GM_util.isGreasemonkeyable(url)) return;
+
+        // Listen for whichever kind of load event arrives first.
+        win.addEventListener('DOMContentLoaded', contentLoad, true);
+        win.addEventListener('load', contentLoad, true);
+
+        runScripts('document-start', win);
+        break;
+      default:
+        dump('Content frame observed unknown topic: ' + aTopic + '\n');
+    }
   }
 };
 
@@ -199,7 +193,6 @@ addMessageListener('greasemonkey:menu-command-run', function(aMessage) {
   MenuCommandRun(content, aMessage);
 });
 
-var contentObserver = new ContentObserver();
 Services.obs.addObserver(contentObserver, 'document-element-inserted', false);
 addEventListener('unload', function() {
   Services.obs.removeObserver(contentObserver, 'document-element-inserted');

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/greasemonkey.git



More information about the Pkg-mozext-commits mailing list