Skip to content

Instantly share code, notes, and snippets.

@Infocatcher
Infocatcher / jxon.js
Created July 18, 2012 16:17
Ugly JXON for Custom Buttons
var xul = {
$tagName: "menupopup",
$xmlns: "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul",
$property: { toString: function() { return "[Object RawProperty]"; } },
$oncommand: function(e) {
alert(e.target.getAttribute("value"));
},
oncommand: "this.oncommand(event);",
$childNodes: [
{ $tagName: "menuitem", label: "Item - 0", value: "0" },
@Infocatcher
Infocatcher / advanceSelectedTab.js
Created August 31, 2012 09:31
Advance select tab for Tree Style Tab and mouse gestures
gBrowser.tabContainer.advanceSelectedTab(1 /* 1 or -1 */, true);
if("TreeStyleTabService" in window) {
const ns = "__mouseGesturesTabsSwitcher__";
var autoExpandDelay = (
"TreeStyleTabUtils" in window
? TreeStyleTabUtils
: TreeStyleTabService
).getTreePref("autoExpandSubtreeOnSelect.whileFocusMovingByShortcut.delay") || 800;
var ts = ns in window && window[ns];
if(!ts) {
@Infocatcher
Infocatcher / cb_repair_broken_overlay.js
Created December 20, 2012 08:16
Repair Custom Buttons after save in Nightly with javascript.options.xml.chrome = false http://custombuttons.sf.net/forum/viewtopic.php?p=2905#p2905
// http://custombuttons.sf.net/forum/viewtopic.php?p=2905#p2905
// (c) Infocatcher 2012
// version 0.1.0 - 2012-12-20
// Repair Custom Buttons after save in Nightly with javascript.options.xml.chrome = false
// Use at your own risk!
// Backup your %profile%/custombuttons directory first!
Components.utils.import("resource://gre/modules/NetUtil.jsm");
Components.utils.import("resource://gre/modules/FileUtils.jsm");
sync(f);
function sync(f) {
var g = f.__generator = f();
g.next();
}
function f() {
var res;
_log("Start first async...");
setTimeout(function() {
@Infocatcher
Infocatcher / dontRememberClosedNewTabs.js
Last active December 11, 2015 13:48
Don't save closed "about:newtab" tabs in undo close history. Only tabs without back/forward history will be removed. You can create Custom Button with this code in initialization.
addEventListener("TabClose", function(e) {
function isNewTabURL(url) {
// See chrome://browser/content/utilityOverlay.js
return url == (window.BROWSER_NEW_TAB_URL || "about:newtab");
}
var tab = e.target;
var browser = tab.linkedBrowser;
if(!isNewTabURL(browser.currentURI.spec))
return;
var sh = browser.sessionHistory;
@Infocatcher
Infocatcher / ChooseColor.js
Last active December 11, 2015 17:08
ChooseColor.js for AkelPad text editor: v.1.7.1 (2012.09.14) + my modifications http://akelpad.sf.net/forum/viewtopic.php?p=8611#8611
// Choose & insert/change color in RGB-format by standard color selection dialog
// supported short format of standard colors
// http://akelpad.sourceforge.net/forum/viewtopic.php?p=8611#8611
// http://outstanding.hmarka.net/akelpad/scripts/ChooseColor.js
// https://gist.github.com/Infocatcher/4632145
// Version: 1.8.1 (2013.08.26) Infocatcher (support for short color format like "#f80")
// Version: 1.8 (2013.01.25) Infocatcher (support for color names like "silver")
// Version: 1.7.1 (2012.09.14) VladSh (warning fixes by Lint)
// Version: 1.7 (2012.09.13) VladSh (bug fixes, added/changed variation of formats of input/output data)
// Version: 1.6.1 (2011.02.16) se7h (autoselect color under caret)
@Infocatcher
Infocatcher / dndTest.js
Created February 28, 2013 15:38
Drag-and-drop test for Gecko-based applications (Firefox & Co)
function dndTest(e) {
var dt = e.dataTransfer;
setTimeout(function() {
var types = dt.types;
var c = dt.mozItemCount;
var r = [];
for(var i = 0, li = types.length; i < li; ++i) {
var type = types.item(i);
r.push(i + ": " + type);
for(var j = 0; j < c; ++j) {
var TU_hookCode = TU_hookMethod;
function TU_hookMethod(aStr) {
try {
var namespaces = aStr.split(".");
try {
var object = this;
while (namespaces.length > 1) {
object = object[namespaces.shift()];
}
@Infocatcher
Infocatcher / tabButtons.js
Last active December 14, 2015 15:59
Tab Buttons example for Firefox/SeaMonkey and Custom Buttons https://addons.mozilla.org/addon/custom-buttons/
// Tab Buttons example for Custom Buttons
// (code for "initialization" section)
// (c) Infocatcher 2013
// version 0.1.0
// Note: this is just an example, added buttons isn't accessible in SeaMonkey.
var tabButtons = {
get btnPrototype() {