firebase and greasemonkey

451 views
Skip to first unread message

Ben Hest

unread,
Apr 7, 2015, 3:57:05 PM4/7/15
to greasemon...@googlegroups.com
I'm trying to see if I can get Firebase working inside a greasemonkey script, but am unable to get it to work. 
  • It worked a-ok inside of tampermonkey. 
  • It worked fine in a stand alone HTML doc after embedding the firebase script and the subesequent code
  • But in Firefox 37.0.1 and GM 3.1 it any changes are not reflected in the Firebase dashboard and I cannot discern any overt errors through the javascript console.
I know it's kind of a stretch asking here, but someone smarter than I might have some idea.

Thanks,
Ben

// ==UserScript==
// @name        indexCache
// @namespace   indexCache
// @include     http://www.SOMEWEBSITE.com/en
// @require     https://cdn.firebase.com/js/client/2.2.3/firebase.js
// @version     1
// @grant       none
// ==/UserScript==


var ref = new Firebase("https://SOMEFIREBASE.firebaseio.com/mine");

ref.on("child_added", function(snapshot) {
  console
.log(snapshot.val());
}, function (errorObject) {
  console
.log("The read failed: " + errorObject.code);
});

ref.push({
  title
: "Hello World!",
  author
: "Firebase",
  location
: {
    city
: "San Francisco",
    state
: "California",
    zip
: 94103
 
}
});
console
.log('pushed Hello World')

ref.push({
  title
: "dude World!",
  author
: "Firebase2",
  location
: {
    city
: "San Franciscos",
    state
: "Californiaaaa",
    zip
: 94103
 
}
});
console
.log('pushed dude World')



Ben Hest

unread,
May 1, 2015, 6:12:20 PM5/1/15
to greasemon...@googlegroups.com
I'm still trying to track down why the firebase @require script loaded through greasemonkey might not be working.  I posted on the firebase forum and they recommended enabling firebase logging.  It came back with this:

p:0: Browser went online.  Reconnecting.  
firebase.js (line 38)
p:0: Listen called for /mine default  
firebase.js (line 38)
0: set {"path":"/mine/-JnXUZccp15pvFDjYXMX","value":{"title":"Hello World!","author":"Firebase","location":{"city":"San Francisco","state":"California","zip":94103}},"Ug":null}  
firebase.js (line 38)
p:0: Buffering put: /mine/-JnXUZccp15pvFDjYXMX  
firebase.js (line 38)
event: /mine:child_added:{"author":"Firebase","location":{"city":"San Francisco","state":"California","zip":94103},"title":"Hello World!"}
firebase.js (line 38)
pushed Hello World
indexCa...user.js (line 29)
0: set {"path":"/mine/-JnXUZcn9gOQJd4w-TmM","value":{"title":"dude World!","author":"Firebase2","location":{"city":"San Franciscos","state":"Californiaaaa","zip":94103}},"Ug":null}  
firebase.js (line 38)
p:0: Buffering put: /mine/-JnXUZcn9gOQJd4w-TmM  
firebase.js (line 38)
event: /mine:child_added:{"author":"Firebase2","location":{"city":"San Franciscos","state":"Californiaaaa","zip":94103},"title":"dude World!"}
firebase.js (line 38)
p:0: Making a connection attempt  
firebase.js (line 38)
c:0:0: Connection created  
firebase.js (line 38)
frame writing exception
firebase.js (line 38)
Wg@file:///C:/Users/xxx/AppData/Roaming/Mozilla/Firefox/Profiles/mhxxxjy.default/gm_scripts/indexCache/firebase.js:166:292
Tg.prototype.open/<@file:///C:/Users/xxx/AppData/Roaming/Mozilla/Firefox/Profiles/mxxxxjy.default/gm_scripts/indexCache/firebase.js:160:222
Tc/c@file:///C:/Users/xxx/AppData/Roaming/Mozilla/Firefox/Profiles/mxxxjy.default/gm_scripts/indexCache/firebase.js:42:105
 
firebase.js (line 38)





c:0:0:0 Timed out trying to connect.  
firebase.js (line 38)
c:0:0:0 Longpoll is closing itself  
firebase.js (line 38)
c:0:0: Realtime connection failed.  
firebase.js (line 38)
c:0:0: Closing realtime connection.  
firebase.js (line 38)
c:0:0: Shutting down all connections  
firebase.js (line 38)
p:0: data client disconnected  
firebase.js (line 38)
p:0: Trying to reconnect in 0ms  
firebase.js (line 38)
0: onDisconnectEvents  
firebase.js (line 38)

One person's summary was this:
Cool.  That confirms that:
  1. You aren't able to connect to Firebase.
  2. For some reason, WebSockets aren't available so we're trying to use long-polling.
  3. Long-polling is failing (which could be for any number of reasons).
Best bet would be to figure out why WebSockets don't work and fix that...  but I don't know enough about GreaseMonkey to know how hard that is.

I've been poking at the code with little success.  I haven't narrowed down the issue, but for posterity's sake, I thought I'd make sure it was documented here in case someone might want to info regarding the topic.

Nils Eriksson

unread,
Oct 27, 2015, 6:42:25 AM10/27/15
to greasemonkey-users
Soo did you get it working ? im haveing the same issue now

Ben Hest

unread,
Oct 27, 2015, 9:28:45 AM10/27/15
to greasemonkey-users
Unfortunately I never did find an answer.

Nils Eriksson

unread,
Oct 27, 2015, 5:17:21 PM10/27/15
to greasemon...@googlegroups.com
I actually got something running now. but only in firefox not in chrome.... 
Maby i should look into the sourcecode.

--
You received this message because you are subscribed to a topic in the Google Groups "greasemonkey-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/greasemonkey-users/eFkd3gj6itA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to greasemonkey-us...@googlegroups.com.
To post to this group, send email to greasemon...@googlegroups.com.
Visit this group at http://groups.google.com/group/greasemonkey-users.
For more options, visit https://groups.google.com/d/optout.

Ben Hest

unread,
Oct 27, 2015, 5:33:57 PM10/27/15
to greasemon...@googlegroups.com
That's weird, I had it running in Chrome, but not Firefox back in April.  The code was verbatim as included in my previous post short of the links being filled in appropriately.
--

-Ben

Nils Eriksson

unread,
Oct 28, 2015, 3:05:42 PM10/28/15
to greasemonkey-users
I have done some further testing. 
Now i work on chrome on the website i want it to work, but not in firefox...
But all is not lost 

"
// ==UserScript==
// @name        firetest
// @namespace   firebase-test
// @include     http://ventureinto.space/
// @version     1
// @grant       GM_util
// @noframe
// ==/UserScript==

var myFirebaseRef = new Firebase("https://YOURFIREBASE.firebaseio.com/");
Firebase.enableLogging(true,true);

myFirebaseRef.set({
  title: "Hello 2324323423",
  author: "Firebase",
  location: {
    city: "San Francisco",
    state: "California",
    zip: 94103
  }
});

"
This works om some websites that uses https. 
like wikipedia but not on others like paypal or github. 
the error im getting is 

"
frame writing exception
firebase.js (line 35)
kh@chrome://greasemonkey-modules/content/sandbox.js -> file:///home/nils/.mozilla/firefox/wjn2h8g3.default/gm_scripts/firetest/firebase.js:172:293
hh.prototype.open/<@chrome://greasemonkey-modules/content/sandbox.js -> file:///home/nils/.mozilla/firefox/wjn2h8g3.default/gm_scripts/firetest/firebase.js:166:223
Rc@chrome://greasemonkey-modules/content/sandbox.js -> file:///home/nils/.mozilla/firefox/wjn2h8g3.default/gm_scripts/firetest/firebase.js:39:52
hh.prototype.open@chrome://greasemonkey-modules/content/sandbox.js -> file:///home/nils/.mozilla/firefox/wjn2h8g3.default/gm_scripts/firetest/firebase.js:166:194
zh/<@chrome://greasemonkey-modules/content/sandbox.js -> file:///home/nils/.mozilla/firefox/wjn2h8g3.default/gm_scripts/firetest/firebase.js:181:208
 
firebase.js (line 35)

"
To unsubscribe from this group and all its topics, send an email to greasemonkey-users+unsub...@googlegroups.com.

To post to this group, send email to greasemon...@googlegroups.com.
Visit this group at http://groups.google.com/group/greasemonkey-users.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "greasemonkey-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/greasemonkey-users/eFkd3gj6itA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to greasemonkey-users+unsub...@googlegroups.com.

To post to this group, send email to greasemon...@googlegroups.com.
Visit this group at http://groups.google.com/group/greasemonkey-users.
For more options, visit https://groups.google.com/d/optout.



--

-Ben
Reply all
Reply to author
Forward
0 new messages