您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
attempts to convert all Farenheit temperature measurments to Celcius. Not infallable, but decent for cooking measurements
// ==UserScript== // @name Convert units to Celcius // @namespace https://github.com/daniel-simpson // @version 0.2 // @description attempts to convert all Farenheit temperature measurments to Celcius. Not infallable, but decent for cooking measurements // @match http://*/* // @copyright 2015+, Daniel Simpson, Melbourne, Australia // ==/UserScript== var config = { pattern: />[^<>]*\s((\d{1,3}(\.\d*)?)[°°\s]{0,2} ?F)\s[^<>]*<\//g, debug: 1, rerun: 5, dp: 3, showTooltip: true }; var generateReplacementString = function(tempF) { var tempC = (((tempF - 32) * 5) / 9).toFixed(config.dp); if(config.showTooltip) { return "<span title='"+tempF+"°F'>" + tempC + "°C</span>"; } return "" + tempC + "°C"; }; var runConversion = function() { if(config.debug) console.log("Starting temperature fix, replacing farenheit with celcius..."); var match = config.pattern.exec(document.body.innerHTML); while(match) { //var itemTextF = match[0]; //Full text node >assudygsudfkujhsdbfjhabsd sadhgfujsh 123F ajshbda</ var replaceTextF = match[1]; //Match including unit 123F var tempF = match[2]; //Temperature value 123 var replaceTextC = generateReplacementString(tempF); if(config.debug) console.log("Replacing " + replaceTextF + " with " + replaceTextC); document.body.innerHTML = document.body.innerHTML.replace(new RegExp(replaceTextF, 'g'), replaceTextC); match = config.pattern.exec(document.body.innerHTML); } if(config.debug) console.log('Completed conversion without errors'); }; for(var i=0;i<config.rerun;i=i+1) { setTimeout(runConversion, 500); }