Skip to content

Instantly share code, notes, and snippets.

@Noitidart
Noitidart / _ff-addon-snippet-winapi_setMouseHook.js
Last active August 27, 2015 21:48
_ff-addon-snippet-winapi_setMouseHook - Uses js-ctypes to set a mouse hook. [jsctypes] [winapi]
Cu.import('resource://gre/modules/ctypes.jsm');
var is64bit = ctypes.voidptr_t.size == 4 ? false : true;
var ifdef_UNICODE = true;
var TYPES = {
ABI: is64bit ? ctypes.default_abi : ctypes.winapi_abi,
CALLBACK_ABI: is64bit ? ctypes.default_abi : ctypes.stdcall_abi,
BOOL: ctypes.bool,
@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 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 / 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.
const {classes: Cc, interfaces: Ci, utils: Cu} = Components;
const self = {
id: 'Bootstrap-Skeleton-Plus',
suffix: '@jetpack',
path: 'chrome://bootstrap-skeleton-plus/content/',
aData: 0,
};
const myServices = {};
Cu.import('resource://gre/modules/Services.jsm');
@Noitidart
Noitidart / _scratchpad-AlertWithinScratchpad
Created February 17, 2014 11:34
In Firefox, when in scratchpad and working in Environment > Browser, if do alert, it alerts in the window behind it, to make the alert happen within the scratchpad window use this technique.
var spwin = Services.wm.getMostRecentWindow(null); //this gets the scratchpad window
var str = 'rawr';
var str = str[0].toUpperCase() + str.substr(1);
spwin.alert(str) // will upper case str this is just to demo the alert comes in the scratchpad window
@Noitidart
Noitidart / oauth_nonce_gen.js
Created February 19, 2014 08:13
OAuth nonce generator function from codebird, its bascially a random string generator.
//https://github.com/jublonet/codebird-js/blob/master/codebird.js#L745
function _nonce(length) {
if (typeof length === "undefined") {
length = 8;
}
if (length < 1) {
console.warn("Invalid nonce length.");
}
var nonce = "";
for (var i = 0; i < length; i++) {