Skip to content

Instantly share code, notes, and snippets.

@heptal
Last active May 7, 2016 16:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save heptal/e2be8faf542bd2b01ebfd2699a0d1c82 to your computer and use it in GitHub Desktop.
Save heptal/e2be8faf542bd2b01ebfd2699a0d1c82 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name SAThreadSearch
// @namespace forums.somethingawful.com
// @version 0.2
// @description Inline thread search
// @author Me
// @match http://forums.somethingawful.com/showthread.php*
// @match https://forums.somethingawful.com/showthread.php*
// @grant none
// ==/UserScript==
(function() {
'use strict';
$('<form action="query.php" method="post" class="threadsearch">')
.append('&nbsp;<input id="searchbox" type="text" placeholder="Search thread" name="q" value="" size="25">&nbsp;')
.append('<input type="submit" class="bginput" name="Submit" value="GO">')
.append('<input type="hidden" name="action" value="query">')
.submit(function(event) {
$('#searchbox').attr('value', function(i, val) {
val = val.replace(/threadid:\d+\s+/g, '');
if (val === "") { event.preventDefault(); return; }
return 'threadid:' + $('#something_awful').data('thread') + ' ' + val;
});
}).insertAfter($('.top .thread_bookmark'));
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment