Skip to content

Instantly share code, notes, and snippets.

// import base Devtools SDK Panel constructor
const { Panel } = require("dev/panel");
// import Devtools SDK Toolbox manager constructor
const { Tool } = require("dev/toolbox");
// import Class helper from the Addon SDK
const { Class } = require("sdk/core/heritage");
// import self module needed to result data resources urls
var self = require('sdk/self');
@nt1m
nt1m / shapes.js
Created July 22, 2015 18:55
Code to generate shape defs
function RegularOctogon(w=0, offset=[0,0]) {
this.w = w;
this.offset = offset;
return this;
}
RegularOctogon.prototype = {
/*
Failed ASCII (regular) octogon
____w____
___
@nt1m
nt1m / svg-cleanup.js
Created August 1, 2015 02:30
svg-cleanup.js
// WIP, most of this doesn't work
var svgns = "http://www.w3.org/2000/svg";
var banned = {
namespaces: ["sketch", "illustrator", "sopodi", "inkscape"],
tags: ["title", "desc"],
tagsIfEmpty: ["defs", "g", "style"],
attributes: ["enable-background", "xml:space", "version"]
};
var invisibleShapesData = {
@nt1m
nt1m / console-diff.js
Last active November 18, 2016 22:59
console.diff(oldObj, newObj)
// This snippet lets you watch for properties removed from an object
console.diff = (object, id) => {
let obj = Object.keys(object);
if (!id) {
id = "diff" + Date.now();
console.lastDiffId = id;
}
let listener = addEventListener("diffEnd", (e) => {
if (id && e.detail.id != id) {
@nt1m
nt1m / main.js
Created August 8, 2016 21:01
frame script
const tabs = require("sdk/tabs");
const { viewFor } = require("sdk/view/core");
let messageManager = viewFor(tabs.activeTab).linkedBrowser.messageManager;
messageManager.loadFrameScript(self.data.url("yourframescript.js"), false);
@nt1m
nt1m / proposal.md
Last active February 25, 2017 14:23
browser.region WebExtension proposal

Interacting with current regions

Supported region IDs

  • navigation_bar
  • tabs_bar
  • find_bar
  • {side}_{end/start}
    • where side is top/left/right/bottom
  • Possibly more UI regions unlikely to change (future proof)

the "browser_region_tweak" manifest field

@nt1m
nt1m / search-proposal.md
Last active February 26, 2017 07:47
Search engines proposal

Adding new search engines: the search_engine manifest field

{
  "search_engine": "opensearch.xml"
}

Managing search engines: the browser.searchEngines namespace

- browser.searchEngines.remove()
function getPositionReference(node) {
let pos = getComputedStyle(node).getPropertyValue("position");
switch (pos) {
case "relative":
return node;
case "absolute":
let parentPosition = "static";
let parent = node.parentNode;
while (parentPosition == "static" && parent.parentNode) {
parent = parent.parentNode;
@nt1m
nt1m / the-plan.md
Last active September 17, 2017 22:15
<iframe mozbrowser> implementation plan for WebExtensions

Implementing iframe mozbrowser> bug 1318532

Opportunities with this API

  • Tile Tabs
  • Create a wrapper around web content (à la Responsive design Mode)
  • Make use of container tabs properties for iframes
  • More secure alternative to overriding CSP to make web content iframe-able
@nt1m
nt1m / face-sad.svg
Last active July 31, 2017 07:35
Preferences SVG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.