Skip to content

Instantly share code, notes, and snippets.

View darkowlzz's full-sized avatar

Sunny darkowlzz

  • ‏‏‏‏‎ ‎
View GitHub Profile
@darkowlzz
darkowlzz / gist:11b2adffd6d1fffbf3f6
Created June 2, 2014 11:10
zest sample - gmail
{
"about": "This is a Zest script. For more details about Zest visit https://developer.mozilla.org/en-US/docs/Zest",
"zestVersion": "0.3",
"title": "sample title",
"description": "sample description",
"prefix": "",
"author": "anon",
"generatedBy": "zest-addon for firefox",
"parameters": "",
"statements": [
@darkowlzz
darkowlzz / addonmanager.js
Created May 13, 2014 12:53
Find if an addon is installed.
const { Cu } = require('chrome');
let { AddonManager } = Cu.import('resource://gre/modules/AddonManager.jsm');
AddonManager.getAddonByID('tabShow@darkowlzz', function(addon) {
if (addon) {
console.log('version: ' + addon.version);
// list all the properties
console.log(JSON.stringify(addon));
}
include: {
is: ['string', 'array', 'regexp', 'object'],
ok: (rule) => {
function checkURL(r) {
if (isRegExpOrString(r))
return true;
if (Array.isArray(r) && r.length > 0)
return r.every(isRegExpOrString);
return false;
const data = require('self').data;
const menuId;
const utils = require('api-utils/window/utils');
const recent = utils.getMostRecentBrowserWindow();
/**
* opts: an options object that includes a name, an image and a callback.
* note: the image can only be a file or data uri, see bug 802003
*/
@darkowlzz
darkowlzz / syncRead.js
Last active August 29, 2015 14:01
synchronous Read using nsIChannel
const { Cu, Ci } = require('chrome');
const { NetUtil } = Cu.import('resource://gre/modules/NetUtil.jsm');
let charset = 'UTF-8';
let channel = NetUtil.newChannel('chrome://foo/content/test-file.txt', charset, null);
// `channel` obtained is an nsIChannel object. Open the channel synchronously.
let stream = channel.open();
// Get the stream length
@darkowlzz
darkowlzz / chrome.manifest
Created May 5, 2014 19:46
Sample chrome.manifest
content foo chrome/content/
@darkowlzz
darkowlzz / asyncCopy.js
Created May 5, 2014 19:09
Copy string to a file asynchronously.
const { Cc, Ci, Cu, components } = require('chrome');
Cu.import('resource://gre/modules/NetUtil.jsm');
// Create a file to write
let file = Cc['@mozilla.org/file/local;1'].
createInstance(Ci.nsILocalFile);
file.initWithPath('/Users/sunny/Desktop');
file.append('test-file.txt');
file.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0666);
@darkowlzz
darkowlzz / selfOutput.txt
Created May 5, 2014 17:56
Result of using `self` for add-on details.
uri: addon:jid1-ddYLv0ZiWhMetw@jetpack
id: jid1-ddYLv0ZiWhMetw@jetpack
preferencesBranch: jid1-ddYLv0ZiWhMetw@jetpack
name: theGreatestAddon
loadReason: install
version: 0.1
packed: true
isPrivateBrowsingSupported: false
@darkowlzz
darkowlzz / detailsSelf.js
Created May 5, 2014 17:50
add-on details using self
const { uri, id, preferencesBranch, name,
loadReason, version, packed, isPrivate } = require('sdk/self');
console.log('\nuri: ' + uri +
'\nid: ' + id +
'\npreferencesBranch: ' + preferencesBranch +
'\nname: ' + name +
'\nloadReason: ' + loadReason +
'\nversion: ' + version +
'\npacked: ' + packed +
@darkowlzz
darkowlzz / output.txt
Last active August 29, 2015 14:01
Output of some @loader/options
id: jid1-ddYLv0ZiWhMetw@jetpack
name: theGreatestAddon
prefixURI: resource://jid1-ddylv0ziwhmetw-at-jetpack/
rootURI: jar:file:///var/folders/m5/53z6crb100z72tmcb_rldn280000gn/T/tmpcZX_yD.mozrunner/extensions/jid1-ddYLv0ZiWhMetw@jetpack.xpi!/
metadata: {"description":"a basic add-on","license":"MPL 2.0","main":"main","name":"theGreatestAddon","version":"0.1","permissions":{}}
version: 0.1
loadReason: install
preferencesBranch: jid1-ddYLv0ZiWhMetw@jetpack