Created
November 30, 2008 06:31
-
-
Save satyr/30394 to your computer and use it in GitHub Desktop.
[Ubiquity] emulates "javascript:"
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
+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