Created
December 2, 2012 04:08
-
-
Save hippietrail/4186914 to your computer and use it in GitHub Desktop.
Convert a search on a StackExchange site to a Google search of that site
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==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); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment