您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Makes 'product' easily copyable, and makes URL to website a hyperlink
// ==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* // @include https://www.ocado.com/webshop/product* // @version 7 // @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 + "' id='website' target='_blank'></a>"); } else if (index == 1) { var product_name = $(this).children("strong").text().trim().replace(' ', ' ').replace(' ', ''); var re = /(\d{1,3})?(\s?\.?x?\s?)(\d{1,4})(\s?)([MmKk]?[LlGg])/; if ((m = re.exec(product_name)) !== null) { if (m.index === re.lastIndex) { re.lastIndex++; } } $(this).children("strong").text(''); $(this).append('<input type="text" value="' + product_name + '" id="product" style="width: 400px;" />'); if (m !== null) { if (m[0]) { $(this).append(' ' + m[0]); $("#product").val($("#product").val().replace(m[0], '')); } } $("#product").css('width', '400px').css('border', 'none'); } }); }); var websiteUrl = 'https://www.ocado.com/webshop/getSearchProducts.do?clearTabs=yes&isFreshSearch=true&chosenSuggestionPosition=&entry=' + encodeURIComponent($("#product").val().trim()); websiteUrl = websiteUrl.replace('%A0', ''); $("#website").attr('href', websiteUrl); $("#product").mouseover(function() { $(this).select(); }); $("#product").mouseout(function() { $(this).select(); }); } if ($("a.shopLink:contains('Browse Shop')").length && document.URL.search('/product') > -1) { $("h2:contains('Nutrition')").wrapInner('<input type="text" id="nutrition" value="Nutrition" />'); $("#nutrition").css('border', 'none'); $("#nutrition").get(0).scrollIntoView(); window.scrollBy(0, -150); }