Skip to content

Instantly share code, notes, and snippets.

@Apocryphon-X
Last active May 20, 2025 03:57
Show Gist options
  • Save Apocryphon-X/c384173ee0b94a352f9fa76ef01f55de to your computer and use it in GitHub Desktop.
Save Apocryphon-X/c384173ee0b94a352f9fa76ef01f55de to your computer and use it in GitHub Desktop.
Este script de Tampermonkey revierte las traducciones automáticas molestas en los resultados de búsqueda de Google. //// This Tampermonkey script reverts the annoying automatic translations in Google search result snippets. It’s important to adapt the script to match the user’s preferred language.
// ==UserScript==
// @name Google ─ Auto‑click “Ver original *”
// @namespace https://tampermonkey.net/users/señor
// @version 1.1.0
// @description Hace clic automáticamente en todos los elementos con jsaction="YjLrZe" cuyo texto comience con "Ver original ", preservando la posición de scroll y evitando rebotes visuales. Es importante adaptar el prefijo al idioma del usuario.
// @author Apocryphon-X (Asistencia: GPT-4o)
// @match *://www.google.com/*
// @grant none
// @run-at document-idle
// ==/UserScript==
(() => {
/* === Parámetros ======================================================== */
const SELECTOR = '[jsaction="YjLrZe"]'; // Atributo guía
const TEXT_PREFIX = 'Ver original'; // Prefijo del tipo "See original"
const LOCK_MS = 300; // ""Debouncing""
/* === 1. Conservar la posición actual del scroll ======================== */
const startX = window.pageXOffset;
const startY = window.pageYOffset;
/* === 2. Ejecutar clic sintético en TODOS los nodos coincidentes ======== */
document
.querySelectorAll(SELECTOR)
.forEach(el => {
if (el.textContent.trim().startsWith(TEXT_PREFIX)) {
el.dispatchEvent(new MouseEvent('click', { bubbles: true, cancelable: true }));
}
});
/* === 3. Mantener el viewport anclado durante LOCK_MS =================== */
const t0 = performance.now();
(function lock(now) {
if (now - t0 < LOCK_MS) {
window.scrollTo(startX, startY);
requestAnimationFrame(lock);
} else {
// Restaurar el comportamiento normal del scroll
document.documentElement.style.overflow = '';
document.body.style.overflow = '';
document.documentElement.style.scrollBehavior = '';
}
})(t0);
})();
@Apocryphon-X
Copy link
Author

Apocryphon-X commented May 13, 2025

SELECTOR value may or may not differ between browsers or user accounts, as this behavior has not been validated across environments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment