Skip to content

Instantly share code, notes, and snippets.

@satyr
Created November 30, 2008 06:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save satyr/30394 to your computer and use it in GitHub Desktop.
Save satyr/30394 to your computer and use it in GitHub Desktop.
[Ubiquity] emulates "javascript:"
+function(){
const Aliases = <pre><![CDATA[({
doc: 'document',
bod: 'document.body',
enc: 'encodeURIComponent',
dec: 'decodeURIComponent',
p: function(x) prompt('Last-Modified: '+ document.lastModified, x),
})]]></pre>;
const Func = (function(b, e){
for(var [k, v] in Iterator(eval(Aliases +''))) b.push(k), e.push(v);
return ['(function('+ b +'){', '}('+ e +'))'];
}([], []));
CmdUtils.CreateCommand({
name: "js",
icon: 'chrome://ubiquity/skin/icons/favicon.ico',
takes: {js: noun_arb_text},
description: 'javascript: ...',
execute: function(input){
var doc = CmdUtils.getDocumentInsecure();
var scr = doc.createElement('script');
scr.textContent = Func.join(input.text);
doc.body.appendChild(scr);
},
preview: '<style>pre {font-family:"Consolas",monospace}</style>'+
Aliases.toXMLString(),
author: 'satyr'.link('http://d.hatena.ne.jp/murky-satyr'),
license: 'MIT',
});
}();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment