Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
puts focus in desired input boxes on sites that are being lame
ruleset a60x475 {
meta {
name "help-me-focus"
description <<
puts focus in desired input boxes on sites that are being lame
>>
author "Mike Grace"
logging on
}
dispatch {
domain ".*"
}
global {
focusData = {
"amazon.com": "#twotabsearchtextbox",
"kynetx.com": "#searchInput",
"stackoverflow.com": "#search input",
"rubygems.org": "#query"
};
currentDomain = page:url("domain");
picker = currentDomain.replace(re/\./g,"\.");
selector = focusData.pick("$.#{picker}");
// a pick that finds nothing returns an empty array
pickFailTest = "#{selector}".replace(re/(ARRAY).*/gi,"$1");
}
rule help_me_focus is active {
select when pageview ".*"
if (pickFailTest neq "ARRAY") then {
emit <|
$input = $K(selector);
try { console.log($input); } catch(e) {}
$input.focus();
$K("<img src='http://dl.dropbox.com/u/1446072/apps/help-me-focus/pointer.png'/>")
.appendTo(document.body)
.hide()
.css({
"position":"absolute",
"top":$input.offset().top - 12,
"left":$input.offset().left - 48,
"z-index":99999
})
.fadeIn("slow")
.delay(4000)
.fadeOut(3000);
|>;
}
}
rule list_sites_that_i_am_helping_on is active {
select when pageview "michaelgrace\.org"
{
emit <|
var builderString = "";
$K.each(focusData, function(index, element) {
builderString += index + "<br>";
});
$K("#focus-list-of-sites").html(builderString);
|>;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment