exports.enable = function (message) {
  var worker = this.getWorker();

  if (worker && worker != -1) {
    this.log('Contacting the content script with message "' + message + '"...');
    worker.port.emit('enable', data.load('page-ruler.html'));
    this.log('Contacting the content script with message "' + message + '"... Done.');
  }
  else {
    this.log('Contact of the content script with message "' + message + '" cancelled.');
  }
};
                onReady : function(tab) {
                    var worker = tab.attach({
                        contentScriptFile: data.url("bridge.js")
                    });

                    worker.port.on('ajax_request', function(_request) {
                        try {
                            worker.postMessage(_request);

                            console.log('Received ajax_request ' + _request);

                            var obj = JSON.parse(_request);

                            var Request = require("request").Request;

                            if (obj.url.indexOf('https://') != 0 && obj.url.indexOf('http://') != 0) {
                                obj.url = data.url(obj.url);
                            }

                            console.log('URL ' + obj.url);

                            // Be a good consumer and check for rate limiting before doing more.
                            var request = Request({
                                url: obj.url,
                                content : obj.data,
                                onComplete: function (response) {
                                    console.log('Response ' + response);

                                    obj.response = response.text;
                                    obj.status = response.status;

                                    worker.port.emit("ajax_response", JSON.stringify(obj));
                                },
                                onError : function(response) {
                                    console.log('On Error');

                                    obj.response = response.text;
                                    obj.status = response.status;

                                    worker.port.emit("ajax_response", JSON.stringify(obj));
                                }
                            });

                            if (obj.type == 'GET') {
                                request.get();
                            } else if (obj.type == 'POST') {
                                request.post();
                            }
                        } catch (e) {
                            console.log(e.message);
                        }
                    });
                }
Example #3
0
		srv.stop(function(){
			//User power-off
			if(prefs.notify)
			{
				require("notifications").notify({
					title: "DivHTTP",
					text: "Server stoped",
					iconURL: data.url("divhttp64.png")
				});
			}
			panel.port.emit("startUI",prefs.defdir,prefs.defport);
		});
Example #4
0
 onRequest: function(request, response) {
   try {
     // All the editor content is located under 'edit:///' so to get a path
     // we just strip that out.
     var path = request.uri.replace('edit:///', '')
     // If requested path was diff from 'edit:///...', then we load editor.
     path = ~path.indexOf('edit:') ? 'index.html' : path
     response.uri = data.url(path)
   } catch(error) {
     console.exception(error)
   }
 }
Example #5
0
exports.getJSONRuleset = function() {
    /* get user settings */
    if(ss.storage.ruleset) {
        return ss.storage.ruleset;
    }

    /* no user rulesets available? use default ruleset */
    var xmlData = data.load('rulesets/default.xml');
    var doc = Helper.converter.parseXML(xmlData);
    
    return Helper.converter.xml2json(doc);
};
Example #6
0
exports.setup = function() {
  PageMod.PageMod({
    include: ['*'],
    contentScriptWhen: 'ready',
    contentScriptFile: data.url('shortcuts.js'),
    onAttach: function onAttach(worker) {
      worker.on('message', function(data) {
        copylink(data);
      });
    }
  });
}
Example #7
0
/* when no valid username or password is entered: displays a login form and resets values and the icon */
function displayloginform() {
    storage.username = '';
    storage.password = '';
    client_id = '';
    user_id = '';
    selecteduserdestination_id = '';
    mainpanel.port.emit('updateform', loginform);
    mainpanel.port.emit('updatelist', '');
    mainpanel.port.emit('resizeonshow');
    timer.clearInterval(queue_timer);
    toolbarbutton.setIcon({url: data.url('assets/img/call-gray.png')});
}
Example #8
0
function calculateReadability(selText) {
	var data = require("self").data;
	console.log("selText:" + selText)
	readability = panel.Panel({
    width: 500,
    height: 600,
	contentURL: data.url("readabilityView.html"),
	contentScriptFile: data.url("update-data.js"),

	onShow: function() {
		console.log(":::::: onShow()");
        this.postMessage(selText); // this message will be captured by the "self.on('message',.." code block in panel.js
    },
	onMessage: function(contentScriptMessage) {
    // Handle message from the content script
	console.log("SEL TEXT that came in: "+contentScriptMessage);
	document.getElementById("inText").innerHTML = contentScriptMessage;
  }
  });
  readability.show();
}
Example #9
0
function createUI(target) {
  require("tabs").open({
    url: data.url("index.html"),
    onReady: function(tab) {
      worker = tab.attach({
        contentScriptFile: data.url("ui.js"),
        contentScriptWhen: "end"
      });
      initializeWorker(target, worker);
    }
  });
}
Example #10
0
	function handleMessage(message) {
		var lang = require("language");
		if(message.length > 0) {
			//TODO: Iconswitch
			var language = student.student(message);
			console.log(language);
			switch(language) {
				case lang.german: 
					widget.contentURL = data.url("./flag/de.png");
					break;
				case lang.spanish: 
					widget.contentURL = data.url("./flag/es.png");
					break;
				case lang.english: 
					widget.contentURL = data.url("./flag/en.png");
					break;
				case lang.french: 
					widget.contentURL = data.url("./flag/fr.png");
					break;
				case lang.norwegian:
					widget.contentURL = data.url("./flag/no.gif");
					break;
				default:
					widget.contentURL = data.url("./keicon.png");
					
			}
			//TODO: response
		}
	}
Example #11
0
exports.matchFile = function (domain) {
    /*
     * This is a problem - if the user has a default.js/css file,  we will always inject
     * causing a bunch of overhead for each tab.
     */
    let files = ['default', domain];

    //  our return object
    let ret = {
        match: false,
        js: [],
        coffee: [],
        css: []
    };

    let jsmatch = false;

    files.forEach(function(filename) {
        let jspath = file.join(homeDir, jsDir, filename);

        if (file.exists(jspath + '.js')) {
            ret.js.push(file.read(jspath + '.js'));
            jsmatch = true;
            ret.match = true;
        }

        if (file.exists(jspath + '.coffee')) {
            if (coffeescript === false)
                coffeescript = data.load('coffee-script.js');
            ret.transpiler = coffeescript;
            ret.coffee.push(file.read(jspath + '.coffee'));
            jsmatch = true;
            ret.match = true;
        }

        let csspath = file.join(homeDir, cssDir, filename);
        if (file.exists(csspath + '.css')) {
            ret.css.push(file.read(csspath + '.css'));
            ret.match = true;
        }
    });

    // we always load jQuery is there is a JS match.
    if (jsmatch === true) {
        if (jquery === false) {
            jquery = data.load('jquery-1.9.0.min.js');
        }
        ret.jquery = jquery;
    }

    return ret;
}
Example #12
0
gallery.port.on("OpenImageNewTab", function(image_url){
    tabs.open({
        inBackground: true,
        url: self.data.url("image.html"),
        onReady: function onReady(tab) {
            var worker = tab.attach({
                contentScriptFile: [self.data.url("jquery-1.6.2.min.js"),
                                    self.data.url("load_image.js")]
            });
            worker.port.emit('OpenImage', image_url);
        }
    });
});
Example #13
0
function prepareToobarButton() {
    toolbarButton = require("toolbarbutton").ToolbarButton({
        id: 'ddg-toolbar-button',
        label: 'DuckDuckGo',
        image: data.url('img/icon_16.png'),
        onCommand: function() {
            var mediator = Cc['@mozilla.org/appshell/window-mediator;1'].getService(Ci.nsIWindowMediator);
            var document = mediator.getMostRecentWindow('navigator:browser').document;      
            var navBar = document.getElementById('ddg-toolbar-button');
            popupPanel.show(navBar);
        }
    });
}
Example #14
0
 var createMenuItemFor = function (kontext) {
   return  contextMenu.Item({
     label: "View Google's cache",
     image: self.data.url ("images/icon.png"),
     context: kontext,
     contentScript: 'self.on("click", function () {' +
       '  self.postMessage();' +
       '});',
     onMessage: function () {
       loadCachedPage ();
     }
   });
 };
Example #15
0
function createLabelousPanel(url) {
    console.log('Creating a panel with url: ' + url);
    var panel = require("panel").Panel({
        width: 360,
        height: 180,
        contentURL: url,
        contentScriptFile: data.url('style-upload.js')
    });
    panel.on("show", function() {
        panel.port.emit("show");
    });
    return panel;
}
Example #16
0
var prepare_close_menu = function() {
    remove_items();

    var close_item = cm.Item({
        label: "Salir del Modo Privado",
        image: data.url("img/privacy16.png"),
        contentScript: 'self.on("click", self.postMessage)',
        onMessage: function() {
            pb.deactivate();
        }
    });
    menuitems.push(close_item);
};
Example #17
0
exports.test_thingy = function(test) {

  // Extract the tests
  var json = _self.data.load("test-msgs.js");
  var tests = JSON.parse(json);

  // Fetch the content script
  var content = _self.data.load("js/bzmail.js");
  content = eval(content);

  console.log(this.bugmail);

  // Each tag names a function which should trigger a change in the contents
  for (var i in tests) {
    var contents = tests[i].contents;
    var tags = tests[i].tags;
  }



  test.assertEqual(5,5);
}
 shortening.shorten(tabs.activeTab.url, function(response) {
   let clipboard = require("clipboard");
   clipboard.set(response.id)
   notifications.notify({
     title: "Copied url: " + response.id + " to the clipboard.",
     text: "Click this notification to test the new Url.",
     data: response.id,
     iconUrl: data.url("google.png"),
     onClick: function(url) {
       tabs.open(url);
     }
   });
 });
Example #19
0
File: main.js Project: rik/longdesk
exports.main = function() {
    pageMod.PageMod({
        include: ["*"],
        contentScriptFile: data.url('pagemod.js'),
        onAttach: function onAttach(worker) {
            worker.on('message', function(message) {
              if (message == 'load-styles') {
                  worker.postMessage({styles: data.load('style.css')});
              }
            });
        }
    });
}
Example #20
0
 serializeDocument: function () {
   this.documentSerializer = this.tab.attach({
     contentScriptFile: data.url("make-static-html.js")
   });
   this.documentSerializer.port.on("SerializedDocument", (function (doc) {
     this.document = doc;
     this.panel.port.emit("Document", doc);
     this.documentSerializer.destroy();
     this.documentSerializer = null;
     this.ExtractorInputReady();
   }).bind(this));
   this.documentSerializer.port.emit("ReceiveDocument");
 },
Example #21
0
gameScorePanel.port.on("gameSelect", function(index, op)
{
    if(gamePref != "")
    {
        var gameId, gameDate, nbaYear, playUrl, vistorTeamName, homeTeamName;
        gameId = gamePref[index]["@attributes"].id;
        gameDate = gamePref[index]["@attributes"].game_date;
        urlDate = gameDate.substr(6,4) + gameDate.substr(0,2) + gameDate.substr(3,2);
        if(gameDate.substr(0,2) > 6 && gameDate.substr(0,2) <= 12)
            nbaYear = gameDate.substr(6,4);
        else
            nbaYear = gameDate.substr(6,4) -1;

        playUrl = "http://data.nba.com/data/10s/html/nbacom/"
                + nbaYear
                + "/gameinfo/"
                + urlDate
                + "/" + gameId;

        if(gameScorePanelType == "gameScore" && (op=="start" || op=="end"))
        {

            playUrl += "_playbyplay_csi.html";

            vistorTeamName = gamePref[index].team[0]["@attributes"].abrv_name;
            homeTeamName = gamePref[index].team[1]["@attributes"].abrv_name;

            if(gamePref[index]["@attributes"].status_numeric == 2 && op == "start")
            {
                resetPlayByPlay();
                var title = "Start live play by play broadcast!";
                var text = vistorTeamName+" vs. "+homeTeamName;
                var icon = data.url("img/myAddon.png");
                sendNotify(title, text, null, null, icon);
                timerId = timer.setInterval(getPlayByPlay ,10000, playUrl, vistorTeamName, homeTeamName);
            }
            if(op == "end" && timerId > 0)
            {
                console.log("end");
                resetPlayByPlay();
            }
        }
        else if (gameScorePanelType == "boxScore")
        {
            playUrl += "_boxscore_csi.html";
            console.log(playUrl);
            getBoxScore(playUrl);
            showPanel(2);
        }
    }
});
Example #22
0
/* handles clicktodial: initiates a call and shows the clicktodial panel. */
function clicktodial(b_number) {
    dialed_number = b_number;
    var username = storage.username;
    var password = storage.password;
    if (username && password) {
        var base64auth = 'Basic ' + btoa(username + ':' + password);
        var content = '{\"b_number\": \"' + b_number.replace(/[^0-9+]/g, '') + '\"}';
        request({
            url: platform_url + 'api/' + clicktodialresource + '/',
            content: content,
            headers: {'Content-type': 'application/json', 'Accept': 'application/json', 'Authorization': base64auth},
            onComplete: function (response) {
                if (response.json != null && response.json['callid'] != null) {
                    // display the clicktodialpanel only if we have a callid
                    callid = response.json['callid'];
                    status_timer = timer.setInterval(updatestatus, 500);
                    clicktodialpanel = panel({
                        width: 302,
                        height: 85,
                        contentScriptFile: [data.url('assets/js/jquery.js'), data.url('assets/js/clicktodialpanel.js')],
                        contentURL: data.url('clicktodial.html'),
                        onHide: function() {
                            timer.clearInterval(status_timer);
                            clicktodialpanel.hide();
                        }
                    });
                    clicktodialpanel.port.on('close', function() {
                        timer.clearInterval(status_timer);
                        clicktodialpanel.hide();
                    });
                    clicktodialpanel.port.emit('updatenumber', b_number);
                    clicktodialpanel.show();
                }
                else {
                    require('notifications').notify({
                        text: 'Het is niet gelukt om het gesprek op te zetten.', // 'The call could not be set up.'
                        iconURL: data.url('clicktodial.gif')
                    });
                }
            }
        }).post();
    }
    else {
        require('notifications').notify({
            text: 'Om gebruik te kunnen maken van Klik en Bel moet eerst ingelogd worden, door op het icoontje op de ' +
                    'toolbar te klikken en je gegevens in te vullen.', 
            // 'In order to use Click to Dial, you first need to log in by clicking the toolbar icon and entering your details.'
            iconURL: data.url('clicktodial.gif')
        });
    }
}
Example #23
0
function Notify(url){
    var myIconURL = data.url("icon64.png");
    var notifications = require("notifications");
    notifications.notify({
        title: "Google+ Share",
        text: "Sharing "+url,
        iconURL: myIconURL,
        onClick: function (data) {
            //console.log("Click");
        }
    });


}
Example #24
0
// open summary page or go to it if already open
function openSummary() {
    var winlen = windows.length;
    for (i=0; i<winlen; i++) {
        var tabslen = windows[i].tabs.length;        
        for (j=0; j<tabslen; j++) {
            if (windows[i].tabs[j].url == "resource://jid0-hynmqxa9zqgfjadreri4n2ahksi-at-jetpack/mind-the-time/data/index.html" ) {
                windows[i].activate();
                windows.activeWindow.tabs[j].activate();
                return
            }
        }
    }    
    tabs.open(data.url("index.html"));
};
Example #25
0
 ExtractorInputReady: function () {
   if ((! this.document) || (! this.extractorChosen)) {
     return;
   }
   this.extractorWorker = Page({
     contentURL: encodeData('text/html', makePage(this.extractorChosen, this.document)),
     contentScriptFile: data.url("extractor-runner.js")
   });
   this.extractorWorker.port.on("Result", this.ExtractorData.bind(this));
   this.extractorWorker.port.on("ErrorResult", (function (error, stack) {
     this.panel.port.emit("Error", "Error in script: " + error + (stack ? "\n" + stack : ""));
   }).bind(this));
   this.extractorWorker.port.emit("StartExtraction", this.extractorChosen['function'], TIMEOUT);
 },
Example #26
0
exports["test sync readURI with ISO-8859-1 charset"] = function(assert) {
  let content = "";

  readURI(data.url("test-uri-io.txt"), {
    sync: true,
    charset: "ISO-8859-1"
  }).then(function(data) {
    content = data;
  }, function() {
    assert.fail("should not reject");
  })

  assert.equal(content, latin1text, "The URL content is loaded properly");
}
Example #27
0
exports["test async readURI"] = function(assert, done) {
  let content = "";

  readURI(data.url("test-uri-io.txt")).then(function(data) {
    content = data;
    assert.equal(content, utf8text, "The URL content is loaded properly");
    done();
  }, function() {
    assert.fail("should not reject");
    done();
  })

  assert.equal(content, "", "The URL content is not load yet");
}
Example #28
0
function initScriptInjection() {

  var filterURL = controller.getWatchListFilterURLs();
  
  var modOptions = {
    include: filterURL,
    onAttach: onCsAttach,
    contentScriptFile: [
      data.url('ui/messageAdapter.js'),
      data.url('common/ui/inline/build/cs-mailvelope.js')
    ],
    contentScript: setDataPathScript(),
    contentStyle: getDynamicStyle()
  }

  if (activePageMod !== undefined) {
    activePageMod.destroy();
  }

  console.log('modOptions.include', modOptions.include);
  activePageMod = pageMod.PageMod(modOptions);

}
Example #29
0
// function to call data.url on arrays
function data_urls(files, base_path) {
  if (!base_path) base_path = ".";

  var urls = [];
  for (var i=0; i<files.length; i++) {
    var path = files[i];
    if (base_path) path = base_path+"/"+path;

    var url = Self.data.url(path);
    urls.push(url);
  }

  return urls;
}
Example #30
0
exports.main = function (options, callbacks) {

	if(!simpleStorage.storage.clientData) {
   		simpleStorage.storage.clientData = {
      			"token": "jxjxmvxyaiwjvt9",
      			"secret": "34s78vlfshegojm"
		};
	} else {
		console.log(simpleStorage.storage.cientData.token + " - " + simpleStorage.storage.clientData.secret);
	}

	var authenticationPanel = panels.Panel({
    		width: 320,
    		height: 120,
    		contentURL: data.url("pages/auth.html"),
    		contentScriptURL: [data.url("script/jquery-1.4.3.min.js"), data.url("script/auth.js")],
    		contentScriptWhen: "ready",
    		onMessage: function(ident) {
      	 		console.log(ident.login + " - " + ident.password);
			dropbox.token(ident.login, ident.password, function (response) {
				console.log(response.status);
				simpleStorage.storage.clientData.token = response.json.token;
				simpleStorage.storage.clientData.secret = response.json.secret;
				console.log(simpleStorage.storage.clientData.token);
				console.log(simpleStorage.storage.clientData.secret);
			});
    		}
	});

	var browserPanel = panels.Panel({
		width: 320,
		height: 120,
		contentURL: data.url("pages/browser.html"),
		contentScriptURL: [data.url("script/jquery-1.4.3.min.js"), data.url("script/browser.js")],
		contentScriptWhen: "ready",
		onMessage: function(login, password) {
			console.log(login + " - " + password);
    		}
	});

	widgets.Widget({
  		label: "DropBox JetPack Addon Configuration",
  		contentURL: data.url("images/favicon.ico"),
  		panel: function() {
     			if(!simpleStorage.storage.clientData.token) {
        			return authenticationPanel;
			} else {
				return browserPanel;
			}
		}()
	});
}