Firefox Addon: How to use gmail.js in Firefox Addon SDK

Well, gmail.js is a very nice script that if you want to work with Gmail (developing browser extensions for Gmail).

The author says that gmail.js is designed for Chrome extension development. There is also many examples about how to use it in Chrome extension. But, how to use it in Firefox addon development?

If you inject it directly in the page, you will got an error: GLOBAL is not defined.

it is because the gmail.js uses 2 variables in the Gmail page, GLOBAL  and also VIEW_DATA. If you inject it directly by pageMode, it can not access any page script.

So you need to modify the gmail.js, in line 6 and 7 (if line number is different, just search it ). By using unsafeWindow , you can access the Gmail page variable:

api.tracker.globals =GLOBALS;

api.tracker.globals = unsafeWindow.GLOBALS;


api.tracker.view_data = typeof VIEW_DATA !== "undefined" ? VIEW_DATA : [];


api.tracker.view_data = typeof unsafeWindow.VIEW_DATA !== "undefined" ? unsafeWindow.VIEW_DATA : [];

Then you can use the gmail.js without error.

Actually in Chrome extension, you can not inject gmail.js with content script decoration in manifest.json directly, because in that way  you can not access GLOBAL too.

You need to use another content script to inject it  with add <script> block in the page, here  is the code snap

window.onload = function () {

    //inject jQuery
    var jq = document.createElement('script');
    jq.src = chrome.extension.getURL("lib/jquery-2.1.1.min.js");

    //inject gmail.js
    var sm = document.createElement('script');
    sm.src = chrome.extension.getURL("lib/gmail.js");
    //inject the script that actual do your things 
    var ct = document.createElement('script');
    ct.src = chrome.extension.getURL("content.js");

Then declare this file as content script in the manifest.json. and also declare all 3 scripts in web_accessible_resources.

BF4:got return from EA after half a month

About half a month ago, I purchased BF4 from

When I was purchasing, there are 3 editions in the store page, standard edition, deluxe edition and premium edition. My friend told me  that the premium edition does not comes with base game. So I purchased the standard edition first and then purchased the premium edition after several days.

Today when another friend asked me to help him purchase BF4 from origin, I found another item called premium membership, I realized that the premium edition actually contains base game. So I tried to ask for return. After I chat with their advisor, told him I placed a wrong order , they gave me return very fast.

I really like EA’s customer service.