您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Highlight hourly rates based on their values.
// ==UserScript== // @name Highlight Hourly Rates on Prolific // @namespace http://tampermonkey.net/ // @version 0.1 // @description Highlight hourly rates based on their values. // @author You // @match *://*/* // @grant MIT // ==/UserScript== (function() { 'use strict'; // Function to extract the numeric value from the string like "£8.16/hr" function extractHourlyRate(text) { return parseFloat(text.match(/[\d.]+/)); } // Function to apply the appropriate background color to the element function highlightElement(element) { const rate = extractHourlyRate(element.textContent); if (rate <= 7.79) { element.style.backgroundColor = 'red'; } else if (rate >= 7.80 && rate <= 9.50) { element.style.backgroundColor = 'yellow'; } else if (rate >= 9.51) { element.style.backgroundColor = 'green'; } // Set the font color to black element.style.color = 'black'; } // Function to process all elements with class="amount" function highlightHourlyRates() { const elements = document.getElementsByClassName('amount'); for (const element of elements) { // Check if the element should be ignored if (element.getAttribute('data-testid') === 'study-tag-reward') { continue; } highlightElement(element); } } // Run the highlighting on page load highlightHourlyRates(); // Observe the DOM for changes and re-run the highlighting if necessary const observer = new MutationObserver(() => { highlightHourlyRates(); }); const config = { childList: true, subtree: true }; observer.observe(document.body, config); })();