Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ento/1137527 to your computer and use it in GitHub Desktop.
Save ento/1137527 to your computer and use it in GitHub Desktop.
Stack Exchange search box animation disabler
// ==UserScript==
// @name Stack Exchange search box grower 1.0
// @namespace stackoverflow
// @description Make Stack Exchange search box grow incrementally
// @include http://stackoverflow.com/*
// @include http://*.stackoverflow.com/*
// @include http://*.stackexchange.com/*
// @include http://serverfault.com/*
// @include http://superuser.com/*
// @include http://stackapps.com/*
// @include http://askubuntu.com/*
// @include http://answers.onstartups.com/*
// @author Alconja
// ==/UserScript==
// http://meta.stackoverflow.com/questions/101387/please-tone-down-or-remove-the-auto-expansion-of-the-search-box/101412#101412
(function() {
function GM_wait() {
if (typeof unsafeWindow.jQuery == 'undefined') {
window.setTimeout(GM_wait,100);
} else {
$ = unsafeWindow.jQuery; letsJQuery();
}
}
GM_wait();
function letsJQuery() {
$(window).load(function() {
var search = $("#search input").css("max-width", "none");
var temp = $("<span></span>").css("font-family", search.css("font-family")).hide().insertAfter(search);
var width = search.width();
search.unbind().bind("keydown keyup", function() {
temp.text($(this).val());
var w = Math.min(Math.max(width, temp.width() + 10), 400);
$(this).clearQueue().animate({width: w + "px"}, 50);
});
});
}
})();
// ==UserScript==
// @name Stack Exchange search box animation disabler 1.0
// @namespace stackoverflow
// @description Removes Stack Exchange search box animation shenanigans
// @include http://stackoverflow.com/*
// @include http://*.stackoverflow.com/*
// @include http://*.stackexchange.com/*
// @include http://serverfault.com/*
// @include http://superuser.com/*
// @include http://stackapps.com/*
// @include http://askubuntu.com/*
// @include http://answers.onstartups.com/*
// @author Nick Craver
// ==/UserScript==
function with_jquery(f) {
var script = document.createElement("script");
script.type = "text/javascript";
script.textContent = "(" + f.toString() + ")(jQuery)";
document.body.appendChild(script);
};
with_jquery(function($) {
$(function() {
$('#search input[name=q]').unbind("focusin focusout").bind({
blur: function() { this.value = this.value === "" ? "search" : this.value; },
focus: function() { this.value = this.value === "search" ? "" : this.value; }
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment