Skip to content

Instantly share code, notes, and snippets.

@grssam
grssam / copyScreenshot.js
Created September 6, 2012 16:14 — forked from grssam/copyScreenshot.js
screenshot copy
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
const { classes: Cc, interfaces: Ci, utils: Cu } = Components;
let EXPORTED_SYMBOLS = [ ];
Cu.import("resource:///modules/devtools/gcli.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
@grssam
grssam / copyScreenshot.js
Created September 6, 2012 11:21
screenshot copy
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
const { classes: Cc, interfaces: Ci, utils: Cu } = Components;
let EXPORTED_SYMBOLS = [ ];
Cu.import("resource:///modules/devtools/gcli.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
@grssam
grssam / exit.js
Created September 6, 2012 09:49
Exit command for GCLI
Components.utils.import("resource:///modules/devtools/gcli.jsm");
gcli.addCommand({
name: "exit",
description: "Exits GCLI and closes the Developer Toolbar",
returnType: "null",
exec: function Exit(args, context) {
let window = context.environment.chromeDocument.defaultView;
let document = window.document;
@grssam
grssam / read_file_per_line.js
Created July 26, 2012 09:32
Read a local file line by line
let {Ci: interfaces, Cc: classes, Cu: utils} = Components;
let ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
let file = ios.newURI(<file address>, null, null).QueryInterface(Ci.nsIFileURL).file;;
let converter = Cc["@mozilla.org/intl/scriptableunicodeconverter"]
.createInstance(Ci.nsIScriptableUnicodeConverter);
converter.charset = /* The character encoding you want, using UTF-8 here */ "UTF-8";
let fis = Cc["@mozilla.org/network/file-input-stream;1"]
.createInstance(Ci.nsIFileInputStream);
fis.init(file, -1, -1, 0);
let lis = fis.QueryInterface(Ci.nsILineInputStream);
@grssam
grssam / s.js
Created July 13, 2012 07:42 — forked from paulrouget/s.js
/* ------- */
// Clean mess from previous session
Components.utils.import("resource:///modules/source-editor.jsm");
let nbox = gBrowser.getNotificationBox();
while (nbox.lastChild.id == "foobar-container" ||
nbox.lastChild.id == "foobar-splitter") {
nbox.removeChild(nbox.lastChild);
}
/* ------- */
// Build container
@grssam
grssam / sorttabs.js
Created June 26, 2012 18:11
Sorts Tabs
/**
* Sort Tabs command
*
* @param number url_part
* a matching string to match the url of tabs.
* if this value is provided, the tabs not matching the criteria would not be shifted.
* @param boolean reverse
* true for reversing the direction of sort
*/
@grssam
grssam / restartCommand.js
Created June 26, 2012 14:05
restart command
/**
* Restart command
*
* @param number delay
* delay in seconds for the restart
* @param boolean disableFastload
* disabled loading from cache upon restart.
*
* Examples :
* >> restart
@grssam
grssam / quotes
Created May 28, 2012 13:38 — forked from paulrouget/quotes
What robcee says
<robcee> where's my hat?,
-------
<robcee> u r teh smartest,
-------
<robcee> I WILL TAKE THIS BULLET FOR YOU,
-------
* robcee swears violently
* robcee continues swearing,
-------
<robcee> hey everybody, forget email. Let's all go skiing. (toboggans also acceptable),
@grssam
grssam / unload.js
Created February 22, 2012 07:00
unload() function
/**
* Provide a way to remove / undo any changes made
* either at the unloading of the script/add-on in which this function is used
* or at the unloading of the container, if provided
*
* @param callback
* function to call when unloading of the script or container.
* This function should undo all the changes made.
* @param container
* Optional, the scope of the function.