Skip to content

Instantly share code, notes, and snippets.

@lachezar lachezar/x.js
Created Sep 24, 2009

What would you like to do?
An Ubiquity command to post the current browser's view in ScreenShootMe (
names: ["shotit"],
arguments: [{role: "object", nountype: noun_arb_text, label: "image format"}],
description: _("Publishes the current browser snapshot on the web and puts a link to it in the clipboard."),
homepage: "",
author: {name: "Lucho Yankov"},
license: "GPL",
preview: _("Publishes the current browser snapshot on the web and puts a link to it in the clipboard."),
help: _("To specify the image format just put 'jpeg' or 'png' as command's parameter, if no format is specified and the image is smaller than 1200KB it will be saved as PNG, otherwise the JPEG format will be used."),
execute: function(args) {
var window = CmdUtils.getWindow();
var canvas = CmdUtils.getHiddenWindow().document.createElementNS("", "canvas");
canvas.mozOpaque = true;
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
canvas.getContext("2d").drawWindow(window, window.scrollX, window.scrollY, window.innerWidth, window.innerWidth, "rgb(255,255,255)");
var data = null;
if (/^j(pe?g)?\s*$/i.test(args.object.text)) {
data = canvas.toDataURL("image/jpeg");
} else if (/^p(ng)?\s*$/i.test(args.object.text)) {
data = canvas.toDataURL("image/png");
} else {
data = canvas.toDataURL("image/png");
if (data.length > 1600*1024) data = canvas.toDataURL("image/jpeg");
displayMessage(_("Sending ") + parseInt(data.length/1024+1) + "KB...", this);
MAIN_URL = "";, "image="+data, function(key) {
if (key == "ERROR") return;
var url = MAIN_URL + "?" + key;
Utils.clipboard.text = url;
displayMessage({text: url, onclick: function(){;}}, this);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.