// ==UserScript== // @name CH MTurk Page Titles // @author clickhappier // @namespace clickhappier // @description Change MTurk page titles to be more specific, instead of most just saying "Amazon Mechanical Turk". // @version 2.1c // @require http://code.jquery.com/jquery-latest.min.js // @match http://www.mturk.com/* // @match https://www.mturk.com/* // @grant GM_log // @downloadURL none // ==/UserScript== var original_title = document.title; // avoid redundancy from what will be appended if (original_title == "Amazon Mechanical Turk - All HITs") { original_title = "Amazon Mechanical Turk"; } else if (original_title == "Amazon Mechanical Turk - HITs Available to You") { original_title = "Amazon Mechanical Turk"; } else if (original_title == "Amazon Mechanical Turk - All Qualifications") { original_title = "Amazon Mechanical Turk"; } else if (original_title == "Amazon Mechanical Turk-Your Pending Qualification Requests") { original_title = "Amazon Mechanical Turk"; } else if (original_title == "Amazon Mechanical Turk - Transfer Earnings") { original_title = "Amazon Mechanical Turk"; } else if (original_title == "Mechanical Turk") // avoid inconsistency { original_title = "Amazon Mechanical Turk"; } // get URL variable - from http://css-tricks.com/snippets/javascript/get-url-variables/ function getQueryVariable(variable) { var query = window.location.search.substring(1); var vars = query.split("&"); for ( var i=0; i -1 ) // for URL used by https://greasyfork.org/scripts/2002-hit-scraper-with-export { document.title = original_title + " - " + "HIT Scraper"; } else if ( $('td.title_orange_text_bold').text().trim() != "" ) // search results pages { if ( document.location.href.indexOf('prevRequester=') > -1 ) // if redirected to 'all HITs' search results from preview/panda link with no more HITs available; if not already included in the URL from accepting a previous HIT in the group, can make a note of the requester name by adding this value to the URL yourself; use + signs for spaces { document.title = original_title + " - was " + decodeURIComponent( getQueryVariable("prevRequester").replace(/\+/g, " ") ) + " - " + $('td.title_orange_text_bold').text().trim() + " - " + $('td.title_orange_text').text().trim(); } else { document.title = original_title + " - " + $('td.title_orange_text_bold').text().trim() + " - " + $('td.title_orange_text').text().trim(); } } else if ( $('td.capsulelink_bold').text().trim() != "" ) // individual HIT/qual pages { if ( $('td.capsule_field_text').first().text().trim() != "" ) { if ( document.location.href.indexOf('qualification') > -1 ) // qual page { document.title = original_title + " - Qual by " + $('td.capsule_field_text').first().text().trim() + " - " + $('td.capsulelink_bold').text().trim(); } else // HIT page { document.title = original_title + " - HIT by " + $('td.capsule_field_text').first().text().trim() + " - " + $('td.capsulelink_bold').text().trim(); } } else { document.title = original_title + " - " + $('td.capsulelink_bold').text().trim(); } } else if ( $('div.contactus form p').first().text().trim() != "" ) // contact pages { if ( document.location.href.indexOf('requesterId=') > -1 ) // contact requester pages { document.title = original_title + " - " + $('div.contactus form p').first().text().trim() + " (" + getQueryVariable("requesterId") + ")"; } else // contact mturk page { document.title = original_title + " - " + $('div.contactus form p').first().text().trim(); } } else if ( $('td.white_text_14_bold').text().trim() != "" ) // dashboard/status/earnings pages { document.title = original_title + " - " + $('td.white_text_14_bold').contents().filter(function(){return this.nodeType == 3;})[0].nodeValue.trim(); // exclude text inside another layer of nested tags such as 'a' or 'span' } else if ( $('td.error_title').text().trim() != "" ) // no search results pages, other error pages { if ( document.getElementById('searchbox').value != "" ) // keyword search with no results { document.title = original_title + " - " + $('td.error_title').text().trim() + " - " + document.getElementById('searchbox').value; } else if ( document.location.href.indexOf('requesterId=') > -1 ) // requester id search with no results { if ( document.location.href.indexOf('prevRequester=') > -1 ) // doesn't appear in these URLs on its own, but can make a note of the requester name by adding this value to the URL yourself; use + signs for spaces { document.title = original_title + " - was " + decodeURIComponent( getQueryVariable("prevRequester").replace(/\+/g, " ") ) + " - " + $('td.error_title').text().trim() + " - " + getQueryVariable("requesterId").replace(/\+/g, " "); } else { document.title = original_title + " - " + $('td.error_title').text().trim() + " - " + getQueryVariable("requesterId").replace(/\+/g, " "); } } else // other error pages { document.title = original_title + " - " + $('td.error_title').text().trim(); } } else if ( $('div.title_orange_text_bold').text().trim() != "" ) // help/policies pages { document.title = original_title + " - " + $('div.title_orange_text_bold').text().trim(); } else if ( $('span#alertboxHeader').text().trim() != "" ) // report-a-HIT confirmation pages { document.title = original_title + " - " + $('span#alertboxHeader').text().trim(); } else if ( document.location.href.indexOf('/qualtable') > -1 ) // for URL used by https://greasyfork.org/scripts/4188-mturk-qualsorter { document.title = original_title + " - " + "QualSorter Table"; } // uncomment (remove the // in front of) the below line to make all titles start with 'AMT' instead of 'Amazon Mechanical Turk' // document.title = document.title.replace("Amazon Mechanical Turk", "AMT");