您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
For Pestpac, adds buttons at the bottom of the tables to copy their information on a specific website
当前为
- // ==UserScript==
- // @name Copy Address Information Buttons
- // @version 1.9
- // @description For Pestpac, adds buttons at the bottom of the tables to copy their information on a specific website
- // @author Jamie Cruz
- // @match https://app.pestpac.com/location/*
- // @grant none
- // @license MIT
- // @namespace https://greasyfork.org/users/1433767
- // ==/UserScript==
- (function() {
- 'use strict';
- function addCopyButton(tableId, buttonText, color) {
- var table = document.getElementById(tableId);
- if (table) {
- // Create and style the button
- 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";
- // Create a new table row and cell
- var newRow = table.insertRow(-1); // Insert row at the end of the table
- var newCell = newRow.insertCell(0);
- newCell.colSpan = table.rows[0].cells.length; // Make the cell span across all columns
- // Insert the button into the new cell
- newCell.appendChild(button);
- // Function to copy table data
- button.addEventListener("click", function() {
- var textContent = table.innerText;
- // Remove unwanted words and extra line breaks
- var cleanedText = textContent.replace(/EMAIL|Map View|Street View|PHONE/g, "").replace(/\n\s*\n/g, "\n").trim();
- // Copy cleaned text to clipboard
- navigator.clipboard.writeText(cleanedText).then(function() {
- alert(buttonText + " copied to clipboard!");
- }).catch(function(err) {
- console.error("Failed to copy table data.", err);
- });
- });
- }
- }
- window.onload = function() {
- addCopyButton("location-address-block", "Copy Location Address", "#1565C0");
- addCopyButton("billto-address-block", "Copy Billto Address", "#1565C0");
- };
- })();