Index: /other-projects/hathitrust/wcsa/vol-checker/WebContent/HT-HTRC_Mashup.user.js
===================================================================
--- /other-projects/hathitrust/wcsa/vol-checker/WebContent/HT-HTRC_Mashup.user.js	(revision 31391)
+++ /other-projects/hathitrust/wcsa/vol-checker/WebContent/HT-HTRC_Mashup.user.js	(revision 31392)
@@ -10,4 +10,5 @@
 // @match       https://babel.hathitrust.org/cgi/ls*
 // @match       https://babel.hathitrust.org/cgi/mb*
+// @match       https://catalog.hathitrust.org/Search/Home*
 // ==/UserScript==
 
@@ -30,6 +31,6 @@
 	var input=$('#q1-input').val();
 	if (input === "") {
-	            return;
-	    }
+	                return;
+	        }
 	event.preventDefault();
 
@@ -46,8 +47,8 @@
 
 	for (var i=0; i<word_len; i++) {
-	            var word = input_words[i];
-	            if (i>0) { full_url += "%2C"; } // append comma
-	            full_url += word_front + word + word_end;
-	        }
+	                var word = input_words[i];
+	                if (i>0) { full_url += "%2C"; } // append comma
+	                full_url += word_front + word + word_end;
+	            }
 
 	full_url += url_end;
@@ -65,8 +66,8 @@
 	var $login_button = $('#login-button');
 	if ($login_button.length) {
-	            $login_button.css('font-size','95%');
-	            $login_button.css('right','-45px');
-	            $login_button.css('width','80px');
-	        }
+	                $login_button.css('font-size','95%');
+	                $login_button.css('right','-45px');
+	                $login_button.css('width','80px');
+	            }
     }
 
@@ -89,4 +90,7 @@
     var $results_a = $('#results_A');
     var results_a_exists = $results_a.length;
+
+    var result_class=".result";
+    var result_access_link_class=".result-access-link";
 
     if (!results_a_exists) {
@@ -98,4 +102,12 @@
     }
 
+     if (!results_a_exists) {
+	 // Perhaps a catalog page search?
+         $results_a = $('form[name="addForm"]');
+         results_a_exists = $results_a.length;
+         result_class = ".resultitem";
+         result_access_link_class = ".AccessLink";
+    }
+
     if (results_a_exists) {
 	//console.log("*** results_a = " + $results_a.html());
@@ -104,38 +116,61 @@
 	//var file_safe_ids = [];
 
-	$results_a.find('.result').each(function() {
-	            var $result_access_link = $(this).find('.result-access-link');
-	            //console.log("*** result access link = " + $result_access_link.html());
-
-	            var $id_link = $result_access_link.find('ul>li>a').first();
-	            //console.log("*** id_link = " + $id_link.html());
-	            var data_clicklog = $id_link.attr("data_clicklog");
-	            //console.log("*** data clicklog= " + data_clicklog);
-
-	            var data_json_str = data_clicklog.replace(/^[a-z]+\|/,"");
-	            //console.log("*** data json= " + data_json_str);
-
-	            var id = null;
-	            if (data_json_str !== "") {
-			    var data_json = JSON.parse(data_json_str);
-			    id = data_json.id;
-			    //console.log("*** (catalog extracted) id= '" + id + "'");
-			        }
-	            else {
-			    var $second_id_link = $result_access_link.find('ul>li>a').eq(1);
-			    console.log("*** 2nd link len = " + $second_id_link);
-			    var id_href = $second_id_link.attr("href");
-			    console.log("*** id href = " + id_href);
-			    id = id_href.replace(/^.*id=/,"");
-			        }
-
-	            ids.push(id);
-	            //var file_safe_id = id.replace(/:/g,"+").replace(/\//g,"=");
-	            //file_safe_ids.push(file_safe_id);
-
-	            $result_access_link.attr("id","htrc-mashup-" + id);
-	            //$result_access_link.attr("id","htrc-mashup-" + file_safe_id);
-
-	        });
+	//$results_a.find('.result').each(function() {
+	//            var $result_access_link = $(this).find('.result-access-link');
+
+	$results_a.find(result_class).each(function() {
+	                var $result_access_link = $(this).find(result_access_link_class);
+
+	                //console.log("*** result access link = " + $result_access_link.html());
+
+	                var $id_link = $result_access_link.find('ul>li>a').first();
+	                //console.log("*** id_link = " + $id_link.html());
+	                var data_clicklog = $id_link.attr("data_clicklog");
+                if (!data_clicklog) {
+                    // fake one from the second <a> href (if present)
+                    $id_link2 = $result_access_link.find('ul>li>a:eq(1)');
+                    if ($id_link2.length>0) {
+                        //console.log("*** id_link2 = " + $id_link2.html());
+                        var id2_href = $id_link2.attr("href");
+                        var id2 = id2_href.replace(/^https:\/\/hdl.handle.net\/\d+\//,"");
+                        data_clicklog = "{\"id\":\"" + id2 + "\"}";
+                    }
+                    else {
+                        data_clicklog="";
+                    }
+                }
+	                //console.log("*** data clicklog= " + data_clicklog);
+
+
+	                var data_json_str = data_clicklog.replace(/^[a-z]+\|/,"");
+	                //console.log("*** data json= " + data_json_str);
+
+	                var id = null;
+	                if (data_json_str !== "") {
+			        var data_json = JSON.parse(data_json_str);
+			        id = data_json.id;
+			        //console.log("*** (catalog extracted) id= '" + id + "'");
+			            }
+	                else {
+			        var $second_id_link = $result_access_link.find('ul>li>a').eq(1);
+			        //console.log("*** 2nd link len = " + $second_id_link);
+			        var id_href = $second_id_link.attr("href");
+			        //console.log("*** id href = " + id_href);
+                    if (id_href) {
+                        //console.log("*** id href = " + id_href);
+                        var encoded_id = id_href.replace(/^.*id=/,"");
+                        id = decodeURIComponent(encoded_id);
+                    }
+                }
+                if (id) {
+                    ids.push(id);
+
+                    //var file_safe_id = id.replace(/:/g,"+").replace(/\//g,"=");
+                    //file_safe_ids.push(file_safe_id);
+
+                    $result_access_link.attr("id","htrc-mashup-" + id);
+                    //$result_access_link.attr("id","htrc-mashup-" + file_safe_id);
+                }
+	            });
 
 	var ids_str = ids.join(",");
@@ -147,43 +182,44 @@
 	console.log("**** Away to request: " + https_servlet_url + "VolumeCheck?ids=" + encodeURIComponent(ids_str));
 
-	var encoded_ids=encodeURIComponent(ids_str);
-	var full_url = https_servlet_url + "VolumeCheck?ids=" + encoded_ids;
-
-	$.ajax(full_url)
+	var check_ids_url = https_servlet_url + "VolumeCheck";
+	//var check_data = { "ids": encodeURIComponent(ids_str) };
+	var check_data = { "ids": ids_str };
+
+	$.post(check_ids_url,check_data)
 	    .done(function(data,textStatus,response) {
 		console.log("Adding in HTRC cross-checks");
 		var ids_exist = data;
 		for (var k in ids_exist) {
-		    //console.log("*** k = '" + k + "'");
-
-		    //var id_str = '#htrc-mashup-'+k;
-		    //console.log("*** id str = " + id_str);
-		    // var $id_div = $(id_str);
-		    
-		    //var $id_div = $('#'+'htrc-mashup-'+k);
-		    var id_div = document.getElementById('htrc-mashup-'+k);
-		    //console.log("*** id_div = " + id_div);
-		    var $id_div = $(id_div);
-
-		    if (ids_exist[k]) {
-			var encoded_id=encodeURIComponent(k);
-			var ef_url = https_servlet_url + "VolumeCheck?download-id=" + encoded_id;
-			var atag = "<a href=\""+ ef_url +"\"><span class=\"icomoon icomoon-download\"></span>Download Extracted Features</a>";
-
-			$id_div.find("ul").append("<li title=\""+k+"\" style=\"color: #924a0b;\">"+atag+"</li>"); // â
+		        //console.log("*** k = '" + k + "'");
+
+		        //var id_str = '#htrc-mashup-'+k;
+		        //console.log("*** id str = " + id_str);
+		        // var $id_div = $(id_str);
+
+		        //var $id_div = $('#'+'htrc-mashup-'+k);
+		        var id_div = document.getElementById('htrc-mashup-'+k);
+		        //console.log("*** id_div = " + id_div);
+		        var $id_div = $(id_div);
+
+		        if (ids_exist[k]) {
+			    var encoded_id=encodeURIComponent(k);
+			    var ef_url = https_servlet_url + "VolumeCheck?download-id=" + encoded_id;
+			    var atag = "<a href=\""+ ef_url +"\"><span class=\"icomoon icomoon-download\"></span>Download Extracted Features</a>";
+
+			    $id_div.find("ul").append("<li title=\""+k+"\" style=\"color: #924a0b;\">"+atag+"</li>"); // â
+			        }
+		        else {
+			    // â, â
+			    $id_div.find("ul").append("<li title=\""+k+"\" style=\"color: red;\">HTRC unfriendly â</li>");
+			        }
+
+		        //console.log("*** id div len = " + $id_div.length);
+
+		        //$.append("<li>HTRC friendly</li>");
 		    }
-		    else {
-			// â, â
-			$id_div.find("ul").append("<li title=\""+k+"\" style=\"color: red;\">HTRC unfriendly â</li>");
-		    }
-
-		    //console.log("*** id div len = " + $id_div.length);
-
-		    //$.append("<li>HTRC friendly</li>");
-		}
-	    })
+		    })
 	    .fail(function(esponse,textStatus,errorThrown) {
 		alert( "error:"  + errorThrown);
-	    });
+		    });
 
 
@@ -200,13 +236,13 @@
 	var $workset_download_button = $('#col-to-workset-download');
 	$workset_download_button.click(function(event) {
-	        event.preventDefault();
+	            event.preventDefault();
 
         var action = $download_form.attr("action");
         //var action_url = action;
 
-	var action_url = https_servlet_url + "VolumeCheck";
+	    var action_url = https_servlet_url + "VolumeCheck";
 
         // Extract hidden elems from, e.g. 
-	//   <input type="hidden" name="c" value="464226859" />
+	    //   <input type="hidden" name="c" value="464226859" />
         //   <input type="hidden" name="a" value="download" />
         //   <input type="hidden" name="format" value="text" />
@@ -223,17 +259,21 @@
 
             var $hidden_input = $(hidden_input);
-	    var hi_name = $hidden_input.attr("name");
-	    var hi_val  = $hidden_input.attr("value");
-	    if (hi_name === "c") {
-		hi_name = "convert-col";
-	    }
-            action_url += hi_name + "=" + hi_value;
+	        var hi_name = $hidden_input.attr("name");
+	        var hi_val  = $hidden_input.attr("value");
+	        if (hi_name === "c") {
+		    hi_name = "convert-col";
+		        }
+            action_url += hi_name + "=" + hi_val;
 
         }
 
-
-	    console.log("workset download url: " + action_url);
-	    window.location.href = action_url;
-	    });
+	    // <title>Collections: Ancestry and Genealogy | HathiTrust Digital Library</title>
+	    var all_col_title = $('title').text();
+        var col_title = all_col_title.replace(/^Collections: /,"").replace(/ \|.*?$/,"");
+	    action_url += "&col-title=" + encodeURIComponent(col_title);
+
+	        console.log("workset download url: " + action_url);
+	        window.location.href = action_url;
+	        });
 
     }
