Skip to content

Instantly share code, notes, and snippets.

@Noitidart
Noitidart / bootstrap.js
Last active January 4, 2016 18:59
This is the source to bootstrap addon "Custom About Page Demo". It demonstrates how to create an about:**** url for the MDN document located here: https://developer.mozilla.org/en-US/docs/Custom_about:_URLs#For_Firefox_4_%28Second_Approach%29
const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr, manager: Cm} = Components;
var selfPath; //note: file system on windows uses \ (forward slash)) but firefox browser uses / (backward slash) //do not edit //the jar will have forward slashes but to navigate so if just want a file within the main folder its selfPath + fileName. but if want folder its selfPath + fileName + '\\'fileInFolder //so as u can see must use forward slashes to navigate folders
Cu.import('resource://gre/modules/XPCOMUtils.jsm');
Cu.import('resource://gre/modules/Services.jsm');
Cm.QueryInterface(Ci.nsIComponentRegistrar);
var AboutModuleUnloaders = [];
function AboutModule() {}
@Noitidart
Noitidart / _template-listenPageLoad-insertElements.xpi
Last active January 4, 2016 20:19
Demo on how to create ff-addon that listens to page loads and inserts a DIV element into it. This example inserts a blue div 200x200 pixels at top left if mozillazine is found in the address. This demo uses the nsIWindowMediatorListener and nsIWindowMediator method.
@Noitidart
Noitidart / bootstrap.js
Created January 29, 2014 10:44
Reseraching how to watch non-gBrowser'ed windows with window listener. Extension of: Demo on how to create ff-addon that listens to page loads and inserts a DIV element into it. This example inserts a blue div 200x200 pixels at top left if mozillazine is found in the address.
const {interfaces: Ci, utils: Cu} = Components;
Cu.import('resource://gre/modules/Services.jsm');
const locationToMatch = 'mozillazine';
function addDiv(theDoc) {
//Cu.reportError('addDiv');
if (!theDoc) {
Cu.reportError('no theDoc!')
//document not provided, it is undefined likely
return;
@Noitidart
Noitidart / bootstrap.js
Created January 30, 2014 07:30
Demo on how to create ff-addon that listens to page loads and inserts a DIV element into it. This example inserts a blue div 200x200 pixels at top left if mozillazine is found in the address. This demo uses an alternative method to window listeners, it uses the observer service and document-element-inserted, this watches chrome windows which do …
const {interfaces: Ci, utils: Cu} = Components;
Cu.import('resource://gre/modules/Services.jsm');
const locationToMatch = 'mozillazine';
function addDiv(theDoc) {
//Cu.reportError('addDiv');
if (!theDoc) {
Cu.reportError('no theDoc!')
//document not provided, it is undefined likely
return;
@Noitidart
Noitidart / bootstrap.js
Created January 31, 2014 08:26
Bootstrap addon demo. Shows how to add a sidebar to all browsing windows. More specifically, a sidebar which allows HTML content.
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
Created February 2, 2014 23:17
This bootstrap addon shows how to add a menu item to the content context menu.
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: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 / gist:8906220
Last active August 29, 2015 13:56
manny42_firefoxExtensionTest_lib_main.js
const {Cc, Ci, Cu, components} = require('chrome');
Cu.import('resource://gre/modules/Services.jsm');
var utils = require("sdk/window/utils");
var tabs = require("sdk/tabs");
var self = require("sdk/self");
var data = self.data;
function createPanel() {
var winsize = tabs.activeTab.attach({
@Noitidart
Noitidart / _template-bootstrapSkeleton.xpi
Last active August 29, 2015 13:56
ff-addon-template: Bare bones of bootstrap addon.