Skip to content

Instantly share code, notes, and snippets.

@satyr
satyr / js.ubiq.js
Created November 30, 2008 06:31
[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);
@satyr
satyr / eval.ubiq.js
Created November 30, 2008 18:24
Evaluates code and displays/copies/sets the result.
const
LLEval = 'http://blog.livedoor.jp/dankogai/archives/51190474.html',
Aliases = <pre><![CDATA[({
ut: Utils,
cu: CmdUtils,
ap: Application,
cw: Utils.currentChromeWindow,
gs: function() CmdUtils.getSelection(),
dm: function(x)(displayMessage({icon: Icon, title: 'eval', text: x}), x),
ss: function(x)(CmdUtils.setSelection(x), x),
// ==UserScript==
// @name AutoLongURLize
// @description Expands shorten/image URLs. (powered by longurl.org)
// @namespace http://d.hatena.ne.jp/murky-satyr
// @include http://twitter.com/*
// ==/UserScript==
const ReLnk = /^\s*https?:/, ReImg = /\.(jpe?g|png|gif)\s*$/;
function alu(d) Array.forEach(d, function(e){
Array.forEach(e.getElementsByTagName('a'), function(a){
with(a) ReLnk.test(innerHTML) && GM_xmlhttpRequest({
@satyr
satyr / tinyur1.ubiq.js
Created December 2, 2008 23:43
[Ubiquity] tinyurl improved
const Name = 'tinyur1',
TURL = 'http://tinyurl.com/',
Selector = '#'+ Name,
Base = <div class={Name}><style><![CDATA[
@.result {text-align:center}
@.arrow {font-weight:bold; margin:2px 0}
@.error {font-style:italic; margin-bottom:4px}
@.logo {
background:#009; font:bold 16px sans-serif; width:6.6em; text-align:center}
@.logo a {color:#fff; text-decoration:none}
@satyr
satyr / gmail.ubiq.js
Created December 12, 2008 04:26
Checks/opens/composes Gmail
const Name = 'gmail',
Gmail = 'https://mail.google.com/mail/',
Base = ''+ <div class={Name}><style><![CDATA[
kbd {font:bold 108% monospace; text-decoration:underline}
dd {margin:0.2em 0 0.8em 1em}
em {line-height:1.8}
.count {font-weight:bolder}
.logo {display:inline-block}
.loading + .logo {opacity:0.4}
]]></style><div id={Name}
@satyr
satyr / restart.ubiq.js
Created December 12, 2008 06:31
Quick-restarts Firefox.
CmdUtils.CreateCommand({
name: 'restart',
icon: 'chrome://ubiquity/skin/icons/arrow_redo.png',
description:
(''+<>Restarts Firefox quickly.
( based on <a href="chrome://mozapps/content/extensions/extensions.js"
>restartApp</a>)</>),
execute: function(){
const os = (Cc['@mozilla.org/observer-service;1']
.getService(Ci.nsIObserverService));
@satyr
satyr / domainColorTab.ubiq.js
Created December 13, 2008 14:07
Colorize each tab by the protocol/domain of its content.
// Colors each tab by the domain of its content.
// original: http://d.hatena.ne.jp/Griever/20081213/1229155926
const DCT_Palette = let(c = '8ace')(
['#'+r+g+b for each(r in c) for each(g in c) for each(b in c)]);
function pageLoad_domainColorTab(doc){
var [dom] = /^\w+:[\/]*[^\/]+/(doc.location.href) || 0;
if(!dom) return;
var tbb, idx = -1, nmr = (Cc['@mozilla.org/appshell/window-mediator;1']
.getService(Ci.nsIWindowMediator)
.getEnumerator('navigator:browser'));
// ==UserScript==
// @name GoogleReaderKeys
// @description Extra keybinds for Google Reader
// @namespace http://d.hatena.ne.jp/murky-satyr
// @include http://www.google.com/reader/view/*
// @include https://www.google.com/reader/view/*
// ==/UserScript==
http://gist.github.com/36459.txt?.user.js
const KE = document.createEvent('KeyEvents')
const Keys = { // C_ : ctrl / A_ : alt / M_ : meta
const Twit = 'http://twitter.com/',
Icon = Twit +'favicon.ico',
PageMax = 40,
Style = <style><![CDATA[
ol{padding:0}
li{margin-left:24px;font-size:80%;clear:left}
li.status{max-width:50em}
a.page{font-weight:bold;margin-right:-12px}
img{border:none}
img.fn{float:left;margin-right:4px}
@satyr
satyr / keys.ubiq.js
Created January 5, 2009 09:49
Extra keybinds for Ubiquity
function ubiquityLoad_keys(U, W){//function cmd_
const Box = U.textBox, Panel = U.msgPanel
bind({
'C_\\': closePanel,
C_j: chain(justExecute, keydown('C_Down')),
C_t: insert('Title'),
'C_u C_l': insert('URL'),
C_o: openPreview,
C_O: inspectPreview,
'C_[': selectFirstWord,