Created
February 8, 2010 12:38
-
-
Save fuba/298111 to your computer and use it in GitHub Desktop.
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 twittersangokushi.googleimage | |
// @namespace http://fuba.moaningnerds.org/ | |
// @include http://ninth.jp/twitter/app/sangoku.php?id=* | |
// @version 0.2 | |
// ==/UserScript== | |
// This code is stolen from http://www.kagami.org/wikipedia_googleimage/wikipedia_googleimage-0.2.user.js | |
(function () { | |
var searchbase = 'http://images.google.co.jp/images?hl=ja&oe=UTF-8&ie=UTF-8&um=1&q='; | |
var apibase = 'http://ajax.googleapis.com/ajax/services/search/images?v=1.0&q='; | |
var word = document.getElementsByTagName('b')[1].innerHTML; | |
var searchurl = searchbase + word; | |
var apiurl = apibase + word; | |
var img = document.createElement('img'); | |
img.alt = 'Google Image Search: ' + word; | |
var a = document.createElement('a'); | |
a.appendChild(img); | |
a.href = searchurl; | |
var p = document.createElement('p'); | |
p.appendChild(a); | |
var txt = document.getElementsByTagName('p')[0]; | |
txt.parentNode.insertBefore(p, txt.nextSibling); | |
GM_xmlhttpRequest({ | |
method: 'GET', | |
url: apiurl, | |
headers: { 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey' }, | |
onload: function(responseDetails) { | |
var res = eval('(' + responseDetails.responseText + ')'); | |
img.src = res.responseData.results[0].tbUrl; | |
} | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What exactly does this script do?