Skip to content

Instantly share code, notes, and snippets.

@ecarnevale
Created March 10, 2009 13:14
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 ecarnevale/76890 to your computer and use it in GitHub Desktop.
Save ecarnevale/76890 to your computer and use it in GitHub Desktop.
A greasemonkey script to automatically redirect a flickr page to IHardlyKnowHer
// ==UserScript==
// @name IHardlyKnowHer
// @namespace http://emanuelcarnevale.com
// @include http://flickr.com/*
// @include http://www.flickr.com/*
// @exclude http://www.flickr.com/photos/friends/*
// ==/UserScript==
function get(url, cb) {
GM_xmlhttpRequest({
method: "GET",
url: url,
onload: function(xhr) { cb(xhr.responseText,url) }
})
}
function goIfAuthorized(text,newLocation) {
//a dumb dumb way to check if the user authorized IHKH to show his photos, but hey, it's just a quick hack ;)
if(!text.match("<div class=\"default\">")){
window.location.href = newLocation;
}
}
(function() {
var newLocation = window.location.href.replace(/flickr\.com\/photos/, 'ihardlyknowher\.com');
get(newLocation, goIfAuthorized);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment