Skip to content

Instantly share code, notes, and snippets.

function findArgs(input, delims, wordBased, leftBranch){
var res = [{'': input}], source = '('+ delims.join('|') +')';
if(wordBased) source = '\\b'+ source +'\\b';
var parts = input.split(RegExp(source));
if(parts.length < 2) return res;
// power sets of delimiter indices
var sets = [[]], {push} = sets;
for(let i = 1, l = parts.length; i < l; i += 2)
@satyr
satyr / selector.ubiq.js
Created May 2, 2009 12:52 — forked from cers/x
CmdUtils.CreateCommand({
name: 'selector-selector',
description: (
<ul style="list-style-image:none">
<li>Lets you type a CSS selector and highlights matched elements.</li>
<li>Hovering on an element creates a matching selector.</li>
</ul>+''),
help: [
[<b>Left-click / Enter</b>,
'Copy and Quit'],
const Name = 'gatherer', Gatherer = 'http://gatherer.wizards.com/',
Base = '<style>\
a img {border:none}\
tr {background-color:inherit !important}\
td {padding:0 .2em 1ex !important; width:auto !important}\
.error {font-style:oblique; line-height:1.8}\
.logo {display:inline-block}\
.logo > img {max-width:100%; vertical-align:middle}\
.loading {opacity:0.9}\
.loading + .logo {opacity:0.4}\
@satyr
satyr / twols.ubiq.js
Last active February 4, 2016 13:39
twitter tools
Cu.import("resource://ubiquity/modules/oauth.js")
const self = this,
H = Utils.escapeHtml,
Twitter = 'http://twitter.com/',
TWS = 'http://search.twitter.com/',
TWAPI = 'https://api.twitter.com/1.1/',
Yats = 'http://yats-data.com/yats/',
twicli = 'http://twicli.neocat.jp/',
Icon = 'chrome://ubiquity/skin/icons/twitter.ico',
Logo = '<a href='+ Twitter +' id=twlogo accesskey="/">'
// 1. Should also work for <img>, <form>, <link>, etc.
// 2. Should also work for html string, DOM, and XML.
// 3. Should return the same (type of) object it received.
function absolutifyUrls(data, baseUrl) {
switch(typeof data){
case "string":
return data.replace(
/\b(href|src|action)=([\"\']?)(?!https?:\/\/)(\S+)\2/ig,
function au_repl(_, a, q, path)(
a + "=" + q + Utils.url({uri: path, base: baseUrl}).spec + q));
/*=skin=
@name empty
@author satyr
=/skin=*/
/* Use Stylish, maybe? */
#ubiquity-preview{}
CmdUtils.CreateCommand({
name: 'email-shortcut-sample',
takes: {message: noun_arb_text},
description:
'http://getsatisfaction.com/mozilla/topics/email_to_a_predefined_address',
execute: function(dob){
(Utils.currentChromeWindow
.gUbiquity.__cmdManager.__cmdSource.getCommand('email')
.execute(context, dob, {to: {text: '[email protected]'}}));
},
diff --git a/ubiquity/feed-parts/header/en/nountypes.js b/ubiquity/feed-parts/header/en/nountypes.js
--- a/ubiquity/feed-parts/header/en/nountypes.js
+++ b/ubiquity/feed-parts/header/en/nountypes.js
@@ -711,17 +711,19 @@ var noun_type_commands = {
}
return cmds;
}
}
var noun_type_twitter_user = {
@satyr
satyr / copy.ubiq.js
Last active October 6, 2016 04:09
Builds a text (from the page title etc.) and sends it to your clipboard.
const
H = Utils.escapeHtml,
Aliases = {
t: {
help: 'title',
get text(){ return info().title },
},
u: {
help: 'URL',
get text(){ return info().url },
// ==UserScript==
// @name GImageHacks
// @namespace http://d.hatena.ne.jp/murky-satyr
// @description Direct links to the image/page + AutoPagerize support
// @include http://*.google.tld/images?*
// ==/UserScript==
directLinkify([document]);
microFormatize(document);
setTimeout(function(){
AutoPagerize.addDocumentFilter(microFormatize);