Skip to content

Instantly share code, notes, and snippets.

View freaktechnik's full-sized avatar
🚞
I like trains

Martin Giger freaktechnik

🚞
I like trains
View GitHub Profile
// Ci is a shorthand for Components.interfaces that has to be defined beforehand.
var enumerator; // is a nsISimpleEnumberator
// Adjust the elementInterface to support your needs / what the enumerator actually provides. Feel free to hard code that instead of doing it this way.
var element, elementInterface = "nsISupports";
while(enumerator.hasMoreElements()) {
element = enumerator.getNext().QueryInterface(Ci[elementInterface]);
// do stuff with element
}
var events = require("sdk/system/events");
var {Ci} = require("chrome");
// See https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIPermissionManager
function listener(event) {
var permission;
// Some events aren't specific to one permission and thus don't have a subject
if(event.subject)
permission = event.subject.QueryInterface(Ci.nsIPermission);
function check() {
// do whatever you want to do
}
// listen when to run again
self.port.on("refresh", check);
// run check when the script is attached
check();
var am = require("sdk/preferences/utils");
var self = require("sdk/self");
// Open the add-on manager with the preference page for this add-on.
am.open(self);
// Returns a promise that resolves once the tab is open.
tabs.open("about:home");
yield wait(tabs, "ready");
assert.ok(main.youtube_download_button.disabled == true);
yield utils.cleanUI();
@freaktechnik
freaktechnik / content-script.js
Last active August 18, 2016 20:03
the l10n get function for content scripts.
function _(id) {
// I'm using self here, but replace it with addon, in case you're loading your content script directly in your html file for a panel
return new Promise((resolve) => {
self.port.once("translated", resolve);
});
self.port.emit("translate", id);
}
// Example usage:
_("anerror").then((string) => {
var string = self.options.myString;
window.addEventListener("load", function() {
//DOM specific stuff here
});
@freaktechnik
freaktechnik / test.js
Last active August 29, 2015 14:20
node-firefox-marketplace minimal test script
var client = new MarketplaceClient("mykey", "mysecret", "development");
client.validatePackage("mines.zip").then(function(result) {
console.log("Result: ", result);
}, function(error) {
console.error(error);
});
$index = 0;
if(count($this->randomTileWeight) > 0) {
$index = $this->randomTileWeight[array_rand($this->randomTileWeight)];
$this->randomTileWeight = array_filter($this->randomTileWeight, function($item) {
return $item != $index;
});
}
diff --git a/debian/control b/debian/control
index 5677472..c3949f1 100644
--- a/debian/control
+++ b/debian/control
@@ -32,6 +32,8 @@ Architecture: any
Depends:
${shlibs:Depends},
${misc:Depends},
+ gstreamer0.10-plugins-base
+Recommends: