Skip to content

Instantly share code, notes, and snippets.

@fuba
Created February 8, 2010 12:38
Show Gist options
  • Save fuba/298111 to your computer and use it in GitHub Desktop.
Save fuba/298111 to your computer and use it in GitHub Desktop.
// ==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;
}
});
})();
@Korb
Copy link

Korb commented Oct 7, 2023

What exactly does this script do?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment