// ==UserScript==
// @name Extraer Todas las Categorías GMB (Copiar) en Maps
// @namespace http://tampermonkey.net/
// @version 1.2
// @description Extrae y permite copiar todas las categorías de GMB de todas las fichas en Google Maps search
// @author [Tu Nombre]
// @match https://www.google.com/maps/search/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
// Crear el botón flotante
let boton = document.createElement('button');
boton.innerText = "Extraer Categorías";
boton.style.position = 'fixed';
boton.style.bottom = '20px';
boton.style.right = '20px';
boton.style.zIndex = '9999';
boton.style.padding = '10px 15px';
boton.style.backgroundColor = '#ff5722';
boton.style.color = 'white';
boton.style.border = 'none';
boton.style.borderRadius = '5px';
boton.style.cursor = 'pointer';
boton.style.fontSize = '14px';
boton.style.boxShadow = '0 4px 6px rgba(0, 0, 0, 0.1)';
document.body.appendChild(boton);
// Función para extraer categorías de todos los contenedores
function extraerCategorias() {
// Selecciona todos los contenedores de categorías en la página
let contenedores = document.querySelectorAll('.category-list-display');
let listaCategorias = [];
// Recorre cada contenedor y extrae sus categorías
contenedores.forEach(contenedor => {
// Selecciona todos los spans que contengan el estilo de fondo (puede ajustarse si varía)
let spans = contenedor.querySelectorAll('span[style*="background-color"]');
spans.forEach(span => {
let texto = span.textContent.trim();
if (texto) {
listaCategorias.push(texto);
}
});
});
// Elimina duplicados
listaCategorias = [...new Set(listaCategorias)];
if (listaCategorias.length > 0) {
mostrarCuadroCopia(listaCategorias.join("\n"));
} else {
alert("No se encontraron categorías.");
}
}
// Función para mostrar el cuadro con el área de texto y botones
function mostrarCuadroCopia(texto) {
let fondo = document.createElement("div");
fondo.style.position = "fixed";
fondo.style.top = "0";
fondo.style.left = "0";
fondo.style.width = "100%";
fondo.style.height = "100%";
fondo.style.backgroundColor = "rgba(0, 0, 0, 0.5)";
fondo.style.zIndex = "10000";
let cuadro = document.createElement("div");
cuadro.style.position = "fixed";
cuadro.style.top = "50%";
cuadro.style.left = "50%";
cuadro.style.transform = "translate(-50%, -50%)";
cuadro.style.backgroundColor = "white";
cuadro.style.padding = "20px";
cuadro.style.borderRadius = "8px";
cuadro.style.boxShadow = "0px 4px 10px rgba(0,0,0,0.3)";
cuadro.style.zIndex = "10001";
cuadro.style.width = "300px";
cuadro.style.textAlign = "center";
let textarea = document.createElement("textarea");
textarea.style.width = "100%";
textarea.style.height = "100px";
textarea.style.marginBottom = "10px";
textarea.style.padding = "10px";
textarea.style.border = "1px solid #ccc";
textarea.style.borderRadius = "5px";
textarea.style.fontSize = "14px";
textarea.value = texto;
let botonCopiar = document.createElement("button");
botonCopiar.innerText = "Copiar";
botonCopiar.style.padding = "10px";
botonCopiar.style.marginRight = "10px";
botonCopiar.style.cursor = "pointer";
botonCopiar.addEventListener("click", function() {
textarea.select();
document.execCommand("copy");
alert("Texto copiado al portapapeles");
});
let botonCerrar = document.createElement("button");
botonCerrar.innerText = "Cerrar";
botonCerrar.style.padding = "10px";
botonCerrar.style.cursor = "pointer";
botonCerrar.addEventListener("click", function() {
document.body.removeChild(fondo);
});
cuadro.appendChild(textarea);
cuadro.appendChild(botonCopiar);
cuadro.appendChild(botonCerrar);
fondo.appendChild(cuadro);
document.body.appendChild(fondo);
}
// Asignar el evento al botón flotante
boton.addEventListener('click', extraerCategorias);
})();
Copyright 2025 © Todos los derechos reservados | Tribu Remota
Menú