Skip to content

Instantly share code, notes, and snippets.

@Noitidart
Noitidart / bootstrap.js
Last active August 29, 2015 13:55 — forked from Noitidart/bootstrap.js
This bootstrap addon shows how to add a menu item to the content context menu. FORK: This fork is different in that it shows how to make that menu item hidden or shown based on if the user opens the popup from a link that contains 'mozilla' in its href.
const {interfaces: Ci,utils: Cu} = Components;
Cu.import('resource://gre/modules/Services.jsm');
/*start - windowlistener*/
var windowListener = {
//DO NOT EDIT HERE
onOpenWindow: function (aXULWindow) {
// Wait for the window to finish loading
let aDOMWindow = aXULWindow.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowInternal || Ci.nsIDOMWindow);
aDOMWindow.addEventListener("load", function () {
@Noitidart
Noitidart / bootstrap.js
Last active August 29, 2015 13:56 — forked from Noitidart/_template-bootstrapSkeleton.xpi
_demo-Bootstrap-nsITimer - Creates a timer that executes callback every 5s, waits for callback to finish, then starts again. Doing TYPE_REPEATING_SLACK with TYPE_ONE_SHOT. This is nice because if used TYPE_REPEATING_PRECISE will trigger this call back every myTimerInterval. TYPE_REPEATING_PRECISE_SKIP will trigger this call back every myTimerInt…
const {classes: Cc, interfaces: Ci, utils: Cu} = Components;
var myTimer = Cc['@mozilla.org/timer;1'].createInstance(Ci.nsITimer);
var myTimerCookie;
var myTimerInterval = 5000;
// we need an nsITimerCallback compatible interface for the callbacks.
var myTimerEvent = {
notify: function(timer) {
Cu.reportError('Timer Fired!');
//do stuff here, this stuff will finish and then timer will start countdown of myTimerInterval.
@Noitidart
Noitidart / _ff-addon-template-BootstrapCustomEventListeners.xpi
Last active August 29, 2015 13:56 — forked from Noitidart/_ff-addon-template-BootstrapWatchHostEventListener.xpi
_ff-addon-template-BootstrapAddEventListenerCustomEvent.xpi - This shows how to listen to and respond to custom events dispatched by web pages.
@Noitidart
Noitidart / _ff-addon-template-BootstrapWatchHostEventListener.xpi
Last active August 29, 2015 13:56 — forked from Noitidart/_template-bootstrapSkeleton.xpi
_ff-addon-template-BootstrapWatchHostEventListener - Uses event listener (DOMContentLoaded) to watch page loads in all tabs and windows with gBrowser. When a page matching a certain host name is found it will inject into it. It also shows you how to attach event listeners to injected elements and elements that were already in the webpage.
@Noitidart
Noitidart / _ff-addon-template-BootstrapWatchHostEventListenerInjectFiles.xpi
Last active August 29, 2015 13:57 — forked from Noitidart/_ff-addon-template-BootstrapWatchHostEventListener.xpi
_ff-addon-template-BootstrapWatchHostEventListenerInjectFiles - Uses event listener (DOMContentLoaded) to watch page loads in all tabs and windows with gBrowser once it finds matching host it will inject files that are packaged with the addon.
@Noitidart
Noitidart / _ff-addon-tutorial-JSCtypesMemmove.js
Last active August 29, 2015 14:03 — forked from nmaier/memmove.md
_ff-addon-tutorial-JSCtypesMemmove - How to use memmove from js-ctypes. Tutorial by @nmaier.
Cu.import('resource://gre/modules/ctypes.jsm');
/*
* Alright then, lets start with copy array `a` into `b`, by reusing and modifying `memset`.
* Note: memset refered to is found here: http://stackoverflow.com/questions/24466228/memset-has-no-dll-so-how-ctype-it
*/
function memcpy(dst, src, size) {
for (var i = 0; i < size; ++i) {
dst[i] = src[i];
}
@Noitidart
Noitidart / _ff-addon-snippet-X11_FocusMostRecentWindowOfPid.js
Last active August 29, 2015 14:06 — forked from Noitidart/_ff-addon-snippet-X11_WindowsMatchingPid.js
_ff-addon-snippet-X11_FocusMostRecentWindowOfPid - Focuses the most recent window given a process id. (js-ctypes) (X11)
Cu.import('resource://gre/modules/ctypes.jsm');
function doit() {
try {
_x11 = ctypes.open('libX11.so.6');
} catch (e) {
try {
var libName = ctypes.libraryName('X11');
} catch (e) {
@Noitidart
Noitidart / lock.c
Last active August 29, 2015 14:06 — forked from anonymous/gist:0ab40694144dfb612335
lock.c - Testing fcntl from c writen by nixeagle
#include <sys/types.h>
#include <unistd.h>
#include <fcntl.h>
#include <stdio.h>
int main() {
int fd;
struct flock lock, savelock;
printf("F_GETLK: %d\n", F_GETLK);