public

Convert a search on a StackExchange site to a Google search of that site

  • Download Gist
ht-se-search-google.user.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
// ==UserScript==
// @name Hippietrail's StackExchange search to Google search
// @description Convert a search on a StackExchange site to a Google search of that site
// @version 0.0
// @namespace hippietrail
// @include http://stackoverflow.com/search*
// @include http://meta.stackoverflow.com/search*
// @include http://serverfault.com/search*
// @include http://meta.serverfault.com/search*
// @include http://superuser.com/search*
// @include http://meta.superuser.com/search*
// @include http://stackapps.com/search*
// @include http://*.stackexchange.com/search*
// @include http://meta.*.stackexchange.com/search*
// ==/UserScript==
 
function main() {
$('#bigsearch tr:last td:first').removeProp('colspan')
.parent().append('<td><input type="button" name="google" value="google"></td>');
 
$('input[name=google]').click(function (event) {
location.href =
'http://google.com'
+ location.pathname
+ location.search + '+site:' + location.hostname;
});
}
 
function addJsNode(func) {
'use strict';
 
var targ = document.getElementsByTagName('head')[0] || document.body || document.documentElement,
scriptNode = document.createElement('script');
 
scriptNode.type = 'text/javascript';
 
scriptNode.textContent = '(' + func.toString() + ')()';
 
targ.appendChild(scriptNode);
}
 
addJsNode(main);

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.