您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Adds buttons to select technicians by area and dates up to 7 days from the latest selected date in the calendar in Pestpac
当前为
// ==UserScript== // @name Pestpac - Easy Quick Scheduler Buttons // @version 3.342620252 // @description Adds buttons to select technicians by area and dates up to 7 days from the latest selected date in the calendar in Pestpac // @match https://app.pestpac.com/appointment/* // @author Jamie Cruz // @grant none // @license MIT // @namespace https://greasyfork.org/users/1433767 // ==/UserScript== (function() { 'use strict'; function addTechButton(buttonText, color, rowRanges) { var button = document.createElement("button"); button.innerHTML = buttonText; button.style.margin = "10px"; button.style.padding = "10px"; button.style.backgroundColor = color; button.style.color = "white"; button.style.border = "none"; button.style.borderRadius = "5px"; button.style.cursor = "pointer"; button.style.width = "88px"; // Adjust the width button.style.height = "25px"; // Adjust the height var refreshSearchButton = document.getElementById("butRefreshSearch"); if (refreshSearchButton) { refreshSearchButton.parentNode.insertBefore(button, refreshSearchButton.nextSibling); } else { console.error("Element with ID 'butRefreshSearch' not found."); } button.addEventListener("click", function() { // Unselect all previously selected rows and remove their class document.querySelectorAll("tr.SelectedRow").forEach(row => { row.dispatchEvent(new MouseEvent('click', { bubbles: true, cancelable: true, view: window })); row.classList.remove("SelectedRow"); }); // Add "SelectedRow" class to specified rows and trigger click event for (let range of rowRanges) { for (let i = range.start; i <= range.end; i++) { let row = document.querySelector("table.insetTable #MultiTechRow" + i); if (row) { row.dispatchEvent(new MouseEvent('click', { bubbles: true, cancelable: true, view: window })); row.classList.add("SelectedRow"); } else { console.error("Row with ID 'MultiTechRow" + i + "' not found."); } } } }); } function addSelectButton(buttonText, color) { var button = document.createElement("button"); button.innerHTML = buttonText; button.style.margin = "5px"; // Adjust the margin for better fit button.style.padding = "1px 3px"; // Adjust the padding for better fit button.style.backgroundColor = color; button.style.color = "white"; button.style.border = "none"; button.style.borderRadius = "5px"; button.style.cursor = "pointer"; button.style.width = "18px"; // Adjust the width button.style.height = "18px"; // Adjust the height var updateCalendarButton = document.getElementById("butUpdateCalendarDate"); if (updateCalendarButton) { updateCalendarButton.style.width = "62px"; // Adjust the width of the update calendar button var newCell = document.createElement("td"); newCell.align = "right"; newCell.appendChild(button); var parentRow = updateCalendarButton.closest("tr"); if (parentRow) { var nextSibling = updateCalendarButton.closest("td").nextElementSibling; if (nextSibling) { parentRow.insertBefore(newCell, nextSibling); } else { parentRow.appendChild(newCell); } // Align the existing cell to the center updateCalendarButton.closest("td").align = "center"; } else { console.error("Parent row of the update calendar button not found."); } // Adjust the table width var parentTable = updateCalendarButton.closest("table"); if (parentTable) { parentTable.style.width = "200px"; // Set the width of the table to 200px } else { console.error("Parent table of the update calendar button not found."); } } else { console.error("Element with ID 'butUpdateCalendarDate' not found."); } button.addEventListener("click", function() { // Find the latest selected date var selectedDates = document.querySelectorAll(".selectedcalendarlink"); if (selectedDates.length === 0) { alert("No date selected."); return; } var latestSelectedDate = selectedDates[selectedDates.length - 1]; var latestDateText = latestSelectedDate.textContent.trim(); var latestDate = new Date(latestDateText); // Select dates up to 7 days from the latest selected date var calendarDates = document.querySelectorAll("table.insetTable .calendarlink, table.insetTable .selectedcalendarlink"); var count = 0; var latestFound = false; for (var i = 0; i < calendarDates.length; i++) { var dateText = calendarDates[i].textContent.trim(); var date = new Date(dateText); if (latestFound && count < 7) { calendarDates[i].dispatchEvent(new MouseEvent('click', { bubbles: true, cancelable: true, view: window })); count++; } if (dateText === latestDateText) { latestFound = true; } } }); } window.onload = function() { // Add tech buttons addTechButton("MD TM", "#de8285", [{ start: 11, end: 13 }, { start: 18, end: 19}]); addTechButton("VA TM", "#ADD8E6", [{ start: 4, end: 4 }, { start: 6, end: 6 }]); addTechButton("MD ACT", "#de8285", [{ start: 11, end: 14 }, { start: 17, end: 20 }]); addTechButton("VA ACT", "#ADD8E6", [{ start: 3, end: 4 }, { start: 6, end: 7 }]); addTechButton("MD techs", "#E03a3e", [{ start: 11, end: 14 }, { start: 17, end: 20 }, { start: 28, end: 28 }, { start: 32, end: 32 }, { start: 35, end: 35 }, { start: 38, end: 38 }]); addTechButton("VA techs", "#00297B", [{ start: 3, end: 10 }]); // Add select button addSelectButton("+7", "#1565C0"); }; })();