// ==UserScript== // @name CH MTurk HIT Link Cleanup // @description On Oct 12, 2016, Amazon added a bunch of useless garbage variables to all the HIT links on MTurk search results pages, making your browser history no longer able to change the link color of HITs you've already visited. This script removes the garbage from those links so your browser history can work properly again. And if you put it first in your userscript execution order, it should also fix some other scripts that were affected by this garbage. // @version 2.0c // @author clickhappier // @namespace clickhappier // @include https://www.mturk.com/mturk/* // @require http://code.jquery.com/jquery-latest.min.js // @grant GM_log // @downloadURL none // ==/UserScript== // get URL variable - adapted from http://css-tricks.com/snippets/javascript/get-url-variables/ to be universal vs window.location-only function getUrlVariable(url, variable) { var query = url.split('?'); var vars = query[1].split("&"); for ( var i=0; i0;) { //reverse iteration as may be destructive if (pars[i].lastIndexOf(prefix, 0)!==-1) { //idiom for string.startsWith pars.splice(i, 1); } } url = urlBase + (pars.length > 0 ? '?' + pars.join('&') : ""); if (fragment[1]) { url += "#" + fragment[1]; } } return url; } $('a[href*="/mturk/preview"]').each(function() { var oldLinkUrl = $(this).attr('href'); var newLinkUrl = oldLinkUrl; // build cleaned HIT links newLinkUrl = removeUrlVariable(newLinkUrl, "rank"); newLinkUrl = removeUrlVariable(newLinkUrl, "sortType"); newLinkUrl = removeUrlVariable(newLinkUrl, "isSelectedBySearchExperiment"); // apply completed url $(this).attr('href', newLinkUrl); });