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 / about.md
Last active April 13, 2022 17:52 — forked from antichris/about.md
Adds a fully functional "Fork" button to your own Gist.

Fork your own Gist

This is a script that adds a fully functional Fork button to your own Gist.

If a Fork button is already present in the page, this bookmarklet will set focus to it instead of adding another one.

The change is temporary and the button will disappear as soon as you navigate away from that Gist (clicking the Fork button does this for you as well). Meaning you will have to run the script every new page load.

Firefox

Copy the contents from bookmarklet.js, open Scracthpad (Ctrl+F4), paste it there. Back in browser, swwitch to tab with your Gist you want to fork. Back in Scratchpad, "Run" it. Save and/or bookmark the Scratchpad file for future use.

@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 / _template-ff-addon-BootstrapURLIconWidget.xpi
Last active December 15, 2017 07:55 — forked from Noitidart/bootstrap.js
_template-ff-addon-BootstrapURLIconWidget - This bootstrap addon shows how to add an icon to the URL bar and when clicked it opens a panel.
@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-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-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];
}