您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Takes the website and fills the last column for every row with random numbers
// ==UserScript== // @name Table Filler // @namespace http://tampermonkey.net/ // @version 1.3 // @description Takes the website and fills the last column for every row with random numbers // @author Doncha1009 // @license MIT // @match https://www.firmtr.com/timecards2?id=* // @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw== // @grant none // ==/UserScript== (function() { 'use strict'; console.log("Started"); const delay = (milliSeconds) => new Promise(resolve => setTimeout(resolve, milliSeconds)); // Get references to the elements const tableBody = document.getElementById('theTableBody'); const moreRowsBtn = document.getElementById('moreRowsBtn'); const minNumber = 0.02; const maxNumber = 0.1; let lastRowIndex = 0; // Loop through each row in the table body and fill it with a random number function fillTableRows() { for (let i = lastRowIndex; i < tableBody.children.length; i++) { const row = tableBody.children[i]; const lastCell = row.lastElementChild; const randomNumber = getRandomNumber(minNumber, maxNumber); // Set the random number as the content of the last cell lastCell.children[0].value = randomNumber; } lastRowIndex = tableBody.children.length; console.log("filled"); } fillTableRows(); // Attach an event listener to the "+ more rows" button moreRowsBtn.addEventListener('click', function() { delay(1000); fillTableRows(); }); // Function to generate a random number between min and max (inclusive) function getRandomNumber(min, max) { const randomDecimal = Math.random(); const scaledRandom = randomDecimal * (max - min); const randomNumber = scaledRandom + min; // Round the random number to two decimal places const roundedNumber = randomNumber.toFixed(2); // Return the rounded random number return parseFloat(roundedNumber); } })();