Greasy Fork

MTurk Check calorie information

Makes 'product' easily copyable, and makes URL to website a hyperlink

当前为 2015-07-17 提交的版本,查看 最新版本

// ==UserScript==
// @name        MTurk Check calorie information
// @description Makes 'product' easily copyable, and makes URL to website a hyperlink
// @namespace   http://idlewords.net
// @include     https://www.mturkcontent.com/dynamic/hit*
// @version     1
// @require     https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js
// @grant       none
// ==/UserScript==

if ($("p:contains('Find the energy kJ per 100 g')").length) {
	$("table>tbody>tr").each(function(index, element) {
		$(this).children("td").each(function(index_c, element) {
			if (index_c == 0) {
				return true;
			} else if (index == 0) {
				var website = $(this).children("strong").text();
				$(this).children("strong").wrapInner("<a href='" + website + "'></a>");
			} else if (index == 1) {
				var product = $(this).children("strong").text();
				$(this).children("strong").text('');
				$(this).append('<input type="text" value="' + product + '" id="product" style="width: 400px;" />');
				$("#product").css('width', '400px').css('border: none');
			}
		});
	});

	$("#product").mouseover(function() {
		$(this).select();
	});
	$("#product").mouseout(function() {
		$(this).select();
	});
}