Skip to content

Instantly share code, notes, and snippets.

@bradhintze
Created December 14, 2010 16:11
Show Gist options
  • Save bradhintze/740639 to your computer and use it in GitHub Desktop.
Save bradhintze/740639 to your computer and use it in GitHub Desktop.
Contest submission by David Godfrey for the Extending the Web contest. Adds Hulu search results to a Netflix search page.
meta {
name "Huflix"
description <<
When searching in Netflix, see up to 3 matched search results for Hulu. Hover over the Hulu logo to see the title of the video and click to go to the video on hulu. Hulu search results are normal free Hulu episodes and Hulu plus.
>>
author "David Godfrey"
// Uncomment this line to require Marketplace purchase to use this app.
// authz require user
logging off
}
dispatch {
domain "netflix.com"
}
global {
datasource hsearch <- "http://www.hulu.com/search"
css <<
.huflix_h_image { background-image:url(http://dl.dropbox.com/u/1244072/logo.png);background-repeat:no-repeat; width: 140px; height: 42px; padding-top: 40px; display:inline-block; }
>>;
}
rule setup is active {
select when pageview "http://www.netflix.com/WiSearch"
pre {
msg = <<
&quot;<span id="huflix_search_term1"></span>&quot; on hulu...
<form style="display:none" id="mySearchForm" onSubmit="return false">
<input name="searchTerm" id="huflix_search_term" type="text" />
<input name="submitter" type="button" />
</form>
>>;
}
{
notify("Searching", msg) with sticky = false and position = "top-left";
watch("#mySearchForm", "submit");
}
}
rule setup_pt2 is active {
select when pageview "http://www.netflix.com/WiSearch"
emit <<
var huflix_search_term_js = $K('#inpageSearchTerm').val();
$K('#huflix_search_term').val(huflix_search_term_js);
$K('#huflix_search_term1').html(huflix_search_term_js);
$K('#mySearchForm').submit();
>>
}
rule setup_chrome is active {
select when pageview "http://movies.netflix.com/WiSearch"
pre {
msg = <<
&quot;<span id="huflix_search_term1"></span>&quot; on hulu...
<form style="display:none" id="mySearchForm" onSubmit="return false">
<input name="searchTerm" id="huflix_search_term" type="text" />
<input name="submitter" type="button" />
</form>
>>;
}
{
notify("Searching", msg) with sticky = false and position = "top-left";
watch("#mySearchForm", "submit");
}
}
rule setup_pt2_chrome is active {
select when pageview "http://movies.netflix.com/WiSearch"
emit <<
var huflix_search_term_js = $K('#searchField').val();
$K('#huflix_search_term').val(huflix_search_term_js);
$K('#huflix_search_term1').html(huflix_search_term_js);
$K('#mySearchForm').submit();
>>
}
rule grab_hulufilx_search_term is active {
select when web submit "#mySearchForm"
pre {
searchTerm = page:param("searchTerm");
huluSearchResults = datasource:hsearch("?query=" + searchTerm + "&st=0&fs=");
msg = <<
Look for this logo: <br />
<span class='huflix_h_image'></span>
>>;
}
emit <<
var huluResults = huluSearchResults;
//console.log(huluSearchResults);
//var HuVidLink = $K('.show-title-container a:contains("Dogs")', huluResults);
//console.log("test");
$K('li.mresult, div.mresult', '#searchResultsPrimaryWrapper').each(function(index) {
//console.log("inside list results");
var huluLinks = "";
//console.log(index, $K(this).find('span.similarsDdWrap .title a.mdpLink').text());
var stringMod = $K(this).find('.similarsDdWrap .title a.mdpLink, .ddWrap .title a.mdpLink').text();
var stringMod1 = "";
for(i=0;i<stringMod.length;i++){
if(stringMod[i] == ":" && stringMod[i+2] == "S"){
i=stringMod.length;
}else{
stringMod1 += stringMod[i];
}
}
//console.log(stringMod1);
//var test = $K(this).find('.similarsDdWrap .title a.mdpLink, .ddWrap .title a.mdpLink').text();
//console.log("FOUND: " + test);
var HuVidLink = $K('.show-title-container a:contains('+$K(this).find('.similarsDdWrap .title a.mdpLink, .ddWrap .title a.mdpLink').text()+'), .show-title-container a:contains('+stringMod1+')', huluResults).each(function(index){
if(huluLinks.length < 350){
huluLinks += "<a style='text-decoration:none' title='"+$K(this).text()+"' target='_blank' href='"+$K(this).attr("href")+"'<span class='huflix_h_image'>"+$K(this).text()+"</span></a>";
}else{
huluLinks += "";
}
});
if(HuVidLink.length > 0){
$K(this).find('.availFormats').append("<span><br /></span>");
$K(this).find('.availFormats').append(huluLinks);
}
});
>>
notify("Done searching hulu", msg) with sticky = false and position = "top-left";
//noop();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment