This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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 | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| tabs.open("about:home"); | |
| yield wait(tabs, "ready"); | |
| assert.ok(main.youtube_download_button.disabled == true); | |
| yield utils.cleanUI(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var string = self.options.myString; | |
| window.addEventListener("load", function() { | |
| //DOM specific stuff here | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var client = new MarketplaceClient("mykey", "mysecret", "development"); | |
| client.validatePackage("mines.zip").then(function(result) { | |
| console.log("Result: ", result); | |
| }, function(error) { | |
| console.error(error); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $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; | |
| }); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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: |